/**
 * Created by Administrator on 2017/4/24.普通类型详情
 * 文章类型
 */
app.controller('detailCtrl',
    ['$scope','$location','$routeParams','$http','$sce','$rootScope', function ($scope,$location,$routeParams,$http,$sce,$rootScope) {
        $("#globalLoading").css({opacity:'1'});
        console.log("上传图片url");
        console.log($("#imgUrl"));

        //获取详情 需要根据fileId
        var articleId = $routeParams.fileId;
        console.log("artarticleId")
        console.log(articleId);

        //首次加载隐藏回到顶部按钮
        $(".baToTop").hide();

        //清空分享数据
        window.shareUrl = '';
        window.shareTitle = "";
        window.shareImg = "";
        window.shareContent = "";
        var shareUrl = $location.absUrl().slice($location.absUrl().indexOf("#") + 1);
        window.shareUrl = globalShareUrl + shareUrl;
        // var articleId=174;文章详情
        $http.jsonp(articleDetailContenUrl + 'articleId=' + articleId + '&jsoncallback=JSON_CALLBACK'
        ).success(function (data, header, config, status) {
          //loading提示
           $("#globalLoading").animate({
               opacity:'0'
           },500);
            //文章分享标题和内容
            window.shareTitle = data.title;
            window.shareContent = data.attAbstract;

            $scope.detailData = data;//获取返回对象
            //添加类型方便评论时判断
            console.log("detailData")
            console.log($scope.detailData.content);
            var topic = data.title;//发送评论使用
            if ($scope.detailData.content.indexOf('<!--IMAGES#1-->') != -1) {
                // 组图单独页面使用
                $scope.multipImageArr = data.images[0].imagearray;

                // 组图图片
                var regs = /<!--IMAGES#1-->/gi;
                var multiPics = "<div style='width:100%;overflow: hidden;padding:2px'>";
                $scope.detailData.content = $scope.detailData.content.replace(regs, function () {

                    for (var j = 0; j < data.images[0].imagearray.length; j++) {
                        console.log(data.images[0].imagearray[j].imageUrl);
                        multiPics += '<img src="' + data.images[0].imagearray[j].imageUrl + '" style="float:left;width: 30%;height: 6.844rem;margin-left: 1%">'
                    }
                    multiPics += "</div>";
                    return multiPics;
                });
                console.log(" multiPics")
                console.log(multiPics)
            }
            var datas = $scope.detailData.content;//获取动态模板
            if (datas.indexOf("body") != -1) {
                var indexA = datas.indexOf("<body>");
                var indexB = datas.indexOf("<\/body>");
                var detailDatass = datas.substring((indexA + 6), indexB);
                console.log("ssss")
                console.log(detailDatass)
            } else {
                detailDatass = $scope.detailData.content
            }
            // 非组图图片
            var i = 0;
            var reg = /<!--IMAGEARRAY#[0-9]{1,}-->/gi;
            detailDatass = detailDatass.replace(reg, function () {

                return '<img src="' + data.images[0].imagearray[i++].imageUrl + '">';
            });


            //后去除去body标签内容
            $scope.con = detailDatass;
            $scope.trustHtml = $sce.trustAsHtml($scope.con);
            console.log("详情")
            console.log(data)

            //是否关闭该篇稿件评论功能
            if (data == "" || data == undefined || data == null) {
                $scope.currentDiscussClosed = 0;
            } else {
                $scope.currentDiscussClosed = data.discussClosed;
            }


            //获取相关稿件
            $scope.Hdata = $scope.detailData.related;
            $scope.detailDataRelated = $scope.detailData.related;
            //相关推荐条数大于1添加下划线
            if ($scope.detailData.related.length > 1) {
                $scope.HdataDeatilBorder = true;
            }

        }).error(function (data, header, config, status) {
        });

        $rootScope.detailAddPraseImag = "static/13.png";
        //点赞 不需要这些userID=22,userOtherID=111,siteID=1,
        $scope.detailAddPrase = function () {
            if (doGetCookie(articleId)) {
                alert("请不要重复点赞");
                return
            } else {
                $scope.detailData.countPraise++;
                $rootScope.detailAddPraseImag = "static/14.png";
                $rootScope.detailAddPraseImagSmall = "static/thuAc.png";
                console.log("useid");
                console.log($scope.uid_fouNder);
                var userID = $rootScope.uid_fouNder

                var id = articleId, type = 0, eventType = 1, channel = 1;
                //提交回复
                $.ajax({
                    type: "post",
                    url: detailPrasieUrl,
                    data: {
                        "id": id,
                        "type": type,
                        "eventType": eventType,
                        "channel": channel
                    },
                    dataType: "jsonp",
                    jsonp: "jsoncallback",
                    jsoncallback: "jsoncallback",
                    success: function (data) {
                        //alert("点赞成功");

                        document.cookie = articleId = 'true';
                    },
                    error: function () {
                        // alert("点赞失败");
                    }
                });
            }

        };
        $rootScope.detailAddStorImagSmall = "static/18.png";
        $rootScope.detailAddStorImag = "static/15.png";
        //收藏
        $scope.detailAddStor = function () {
            if (uid_fouNder) {
                var userID = uid_fouNder;
                $rootScope.detailAddStorImagSmall = "static/19.png";
                $rootScope.detailAddStorImag = "static/16.png";
                var userID = userID, siteID = 1, type = 0, id = articleId, channel = 0;
                //提交回复
                $http.jsonp(artDetailAddStorUrl + 'userID=' + userID + '&siteID=' + siteID + '&type=' + type + '&id=' + id + '&channel' + channel + '&jsoncallback=JSON_CALLBACK'
                ).success(function (data, header, config, status) {
                    console.log("收藏成功");
                }).error(function (data, header, config, status) {

                });
            } else {
                alert("请登录后收藏");
                //$scope.h5Jump('http://59.108.92.239:9081/SSOv2/user/ssoLogin?code=yxapp&redirectUrl=http://59.108.92.239/amucsite/pad/sso/setCookie.html?&anyUrl=http://59.108.92.239/amucsite/pad/index.html#/detail/'+articleId+'&isAppType=app');
                ssologin();
            }
        };


        /**
         * 文章详情评论，与其他评论source不同
         * */
        var source = artSource;
        //获取最新评论  page=0开始;加载更多评论
        var compage = 0;
        //加载更多最新评论（只有最新评论有分页）id=3969全替换为articleId*****
        $scope.LoadMoreCom = function () {
            compage++;
            $http.jsonp(newComment + 'id=' + articleId + '&siteId=1&lastFileId=0&page=' + compage + '&source=' + source + '&jsoncallback=JSON_CALLBACK'
            ).success(function (data, header, config, status) {
                // 是否还有更多评论
                $scope.hasMorCom = data.hasMore;
                $scope.commenCon = $scope.commenCon.concat(data.list);
            }).error(function (data, header, config, status) {

            });

        };

        //获取最新评论
        $scope.getNewCom = function () {

            //判断登录与否
            $scope.commeInputs = siteConfig.defaultHint;
            $('#commeInputs').val($scope.commeInputs);
            //'+articleId+'  '+source+' 3969
            $http.jsonp(newComment + 'id=' + articleId + '&siteId=1&lastFileId=0&page=0&source=0&jsoncallback=JSON_CALLBACK'
            ).success(function (data, header, config, status) {
                console.log("第一次最新评论");
                console.log(data);
                // 是否还有更多评论
                $scope.hasMorCom = data.hasMore;
                $scope.commenCon = data.list;
                $scope.totalCount = data.totalCount;
            }).error(function (data, header, config, status) {

            });
        };

        //// 加载详情页时先加载最新评论一次，顺序问题,不能放getNewCom方法前
        //$scope.getNewCom();

        // 首个input
        // 首个时，这几个参数是不是可以没有？？parentID = $scope.parentId, parentUser = $scope.userName,
        //     parentUserID = $scope.ParentUserID,  userID = logUserId
        //$("#commeInputs").focus(function () {





        //提交顶部评论信息
        $scope.sendComFistBtn = function () {
            //只提交文字评论，无图片
            console.log(window.uploadFile);
            if(!window.uploadFile){
                    var sendMesg = $("#commeInputs").val();
                    console.log("信息");
                    console.log(sendMesg);
                    //var logUserId=$rootScope.uid_fouNder;
                    var logUserId = uid_fouNder;
                    console.log("评论用户id")
                    console.log(logUserId);
                    var LogUserName = username_fouNder;
                    //匿名评论
                    if(!uid_fouNder){
                        logUserId=0;
                        LogUserName="pc用户";
                    }

                    var siteID = 1, rootID = articleId, parentID = 0, parentUser = '',
                        parentUserID = 0, topic = topic, userID = logUserId
                        , userName = LogUserName, type = 0, content = sendMesg;

                    //提交回复
                    $.ajax({
                        type: "post",
                        url: sentComent,
                        data: {
                            "siteID": siteID,
                            "rootID": rootID,
                            "parentID": parentID,
                            "parentUser": parentUser,
                            "parentUserID": parentUserID,
                            "topic": topic,
                            "userID": userID,
                            "userName": userName,
                            "type": type,
                            "content": content,
                            "channel": 0,
                            "sourceType": source
                        },
                        dataType: "json",
                        //jsonp: "jsoncallback",
                        //jsoncallback:"jsoncallback",
                        //crossDomain:true,
                        success: function (data) {
                            if (data) {
                                console.log(data);
                                alert("评论成功！");
                                $scope.getNewCom();
                                console.log("发送内容为：");
                                console.log(sendMesg);
                                $("#commeInputs").val("");
                            } else {
                                alert("评论失败！1");
                            }
                        },
                        error: function () {
                            alert("评论失败！2");
                            $("#commeInputs").val("");
                        }
                    });
            //有图片时发送评论
            }else{


                            //图片提交
                            var uploadFile=window.uploadFile;
                            console.log(window.uploadFile);
                            var formdata = new FormData();
                            formdata.append("Filedata", uploadFile);
                            formdata.append("siteID", 1);
                            formdata.append("location", 0);
                            formdata.append("userId", "0");
                            formdata.append("fileType", "picture");
                            formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                            $.ajax({
                                type:'POST',
                                url: commUpload,
                                processData: false,
                                data: formdata,
                                async:false,
                                contentType: false,    //这个一定要写
                                dataType:'json',
                                success: function(result){
                                    //成功后处理代码
                                    //self.onSuccess(file, result);
                                    //if(self.curUploadFile.length==0){
                                    // 回调全部完成方法
                                    //self.onComplete("全部完成");
                                    console.log("result");
                                    console.log(result)
                                    console.log("上传成功url");
                                    var comimgUrl=JSON.parse(result).fileList[0].url;
                                    console.log(comimgUrl);

                                    setTimeout(function(){
                                        //评论成功之后提交回复
                                        var sendMesg=$("#commeInputs").val();
                                        console.log("评论信息");
                                        console.log(sendMesg);
                                        var logUserId=uid_fouNder;
                                        var LogUserName=username_fouNder;
                                        //匿名评论
                                        if(!uid_fouNder){
                                            logUserId=0;
                                            LogUserName="pc用户";
                                        }
                                        var topicTitle= $scope.detailData.title;
                                        var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                                            parentUserID = $scope.ParentUserID, topic =topicTitle, userID=logUserId
                                            , userName=LogUserName, type = 0,content=sendMesg;

                                        //提交回复
                                        $.ajax({
                                            type: "post",
                                            url: sentComent,
                                            data:{
                                                "siteID": siteID,
                                                "rootID": articleId,
                                                "parentID": parentID,
                                                "parentUser": parentUser,
                                                "parentUserID": parentUserID,
                                                "topic": topic,
                                                "userID": userID,
                                                "userName": userName,
                                                "type": type,
                                                "content":content,
                                                "channel":1,
                                                "sourceType":artSource,
                                                "imgUrl":comimgUrl

                                            },
                                            dataType : "json",
                                            //jsonp: "jsoncallback",
                                            //jsoncallback:"jsoncallback",
                                            success: function(data){
                                                    console.log(data);
                                                    alert("评论图片上传成功！");
                                                    $scope.getNewCom();
                                                    //图片上传成功后，清除当前图片，设置可以重新添加上传图片
                                                    $('.img-cont').text("");
                                                    $("#file").attr("disabled", false);
                                                    //清除全局变量图片
                                                    window.uploadFile="";

                                            },
                                            error: function(){
                                                alert("评论失败！2");
                                                $('#commentModle').css('display',"none");
                                                $("#commentArea").css('display',"none");
                                                $("#comm_text_footer").css('display',"block");
                                            }
                                        });
                                    },2000)

                                    //}
                                },
                                error: function(){
                                    self.onFailure(file);
                                }

                            });

            }
        };





            //获取 热门评论 id = '+articleId+'??
            $scope.getHotCom=function () {
                $http.jsonp(hotComment+'id='+articleId+'&siteId=1&source='+source+'&jsoncallback=JSON_CALLBACK'
                ).success(function(data,header,config,status){
                    console.log(data);
                    // 是否还有更多评论
                    $scope.hasMorCom=data.hasMore;
                    //获取评论
                    $scope.commenCon=data.list;
                }).error(function(data,header,config,status){
                });
            };

        //文章类型获取全局配置信息
        $scope.getCommentInfo=function(){
            $http.jsonp(commInfo+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("全局评论信息");
                console.log(data);
                $scope.siteConfig=data.siteConfig.discuss;
                //评论框提示语
                siteConfig.defaultHint=$scope.siteConfig.defaultHint;
                //官方评论用户名
                siteConfig.defaultName=$scope.siteConfig.defaultName;
                $scope.defaultName=$scope.siteConfig.defaultName;
                //官方评论头像
                siteConfig.defaultIcon=$scope.siteConfig.defaultIcon;
                $scope.siteConfigDefaultIcon=$scope.siteConfig.defaultIcon;
                console.log("官方用户名");
                console.log($scope.defaultName);
                //是否关闭全站评论功能
                $scope.siteConfigAuditType=$scope.siteConfig.auditType;
                console.log("全局关闭");
                console.log($scope.siteConfigAuditType);
                //全局评论颜色问题
                $scope.commStyleColor=$scope.siteConfig.styleColor;
                commentStyle=$scope.commStyleColor;
                $rootScope.changeComStyle();

                $scope.getNewCom();
                //setTimeout(function () {

                //},1000)
            }).error(function(data,header,config,status){

            });

        };
        $scope.getCommentInfo();
        //获取最新和热门评论




            //文章回复评论点击功能
            $scope.replayCom=function ($event,userName) {
                    var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
                    console.log("current")
                    console.log(currInputPar)
                    $(currInputPar).each(function(index,val){
                        if(val.className.indexOf('comm_con_input_par')!=-1){
                            var cureInput=val;
                            if($(cureInput).hasClass('hideInput')){
                                $(cureInput).removeClass("hideInput");
                            }else{
                                $(cureInput).addClass("hideInput");
                            }
                        }
                    })


                    var currInput= $(currInputPar[4]).find("input");
                    $(currInput).attr("placeholder","@"+userName+":");
                    $(currInput).focus();

            };
            //文章评论提交
            $scope.par_input_send=function ($event,parentId,userName,ParentUserID) {
                $scope.parentId = parentId;
                console.log($scope.parentId)
                $scope.userName = userName;
                console.log($scope.userName)
                $scope.ParentUserID = ParentUserID;
                console.log($scope.ParentUserID)
                console.log(window.uploadFile);
                if(!window.uploadFile) {
                    //只提交文字
                    var currInput = angular.element($event.target).parent().parent().find("input");
                    console.log($(currInput).val());
                    var sendMesg = $(currInput).val();
                    var pareDiv = angular.element($event.target).parent().parent()
                    // 提交评论使用
                    $scope.parentId = parentId;
                    console.log($scope.parentId)
                    $scope.userName = userName;
                    console.log($scope.userName)
                    $scope.ParentUserID = ParentUserID;
                    console.log($scope.ParentUserID)
                    var logUserId = uid_fouNder;
                    console.log("评论用户id")
                    console.log(logUserId)
                    var LogUserName = username_fouNder;
                    var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                        parentUserID = $scope.ParentUserID, topic = topic, userID = logUserId
                        , userName = LogUserName, type = 0, content = sendMesg;

                    //提交回复
                    $.ajax({
                        type: "post",
                        url: sentComent,
                        data: {
                            "siteID": siteID,
                            "rootID": rootID,
                            "parentID": parentID,
                            "parentUser": parentUser,
                            "parentUserID": parentUserID,
                            "topic": topic,
                            "userID": userID,
                            "userName": userName,
                            "type": type,
                            "content": content,
                            "channel": 0,
                            "sourceType": source
                        },
                        dataType: "json",
                        //jsonp: "jsoncallback",
                        //jsoncallback:"jsoncallback",
                        success: function (data) {
                            if (data) {
                                console.log(data);
                                alert("评论成功！");
                                $scope.getNewCom();
                                console.log("发送内容为：");
                                console.log(sendMesg);
                                $(currInput).val("");
                                $(pareDiv).addClass('hideInput');
                            } else {
                                alert("评论失败！1");
                            }

                        },
                        error: function () {
                            alert("评论失败！2");
                            $("#comInput").val("");
                            $(pareDiv).addClass('hideInput');
                        }
                    });
                }else{
                    //既有图片又有文字的评论回复
                    //图片提交
                    var uploadFile=window.uploadFile;
                    console.log(window.uploadFile);
                    var formdata = new FormData();
                    formdata.append("Filedata", uploadFile);
                    formdata.append("siteID", 1);
                    formdata.append("location", 0);
                    formdata.append("userId", "0");
                    formdata.append("fileType", "picture");
                    formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                    $.ajax({
                        type:'POST',
                        url: commUpload,
                        processData: false,
                        data: formdata,
                        async:false,
                        contentType: false,    //这个一定要写
                        dataType:'json',
                        success: function(result) {
                            //成功后处理代码
                            //self.onSuccess(file, result);
                            //if(self.curUploadFile.length==0){
                            // 回调全部完成方法
                            //self.onComplete("全部完成");
                            console.log("result");
                            console.log(result)
                            console.log("上传成功url");
                            var comimgUrl = JSON.parse(result).fileList[0].url;
                            console.log(comimgUrl);
                            //获取图片url后再调用接口
                            setTimeout(function(){
                                var currInput = angular.element($event.target).parent().parent().find("input");
                                console.log($(currInput).val());
                                var sendMesg = $(currInput).val();
                                var pareDiv = angular.element($event.target).parent().parent();
                                console.log(angular.element($event.target).parent().children().find(".imgCont"));
                                //清空上传的图片内容
                                var currentImgCon=angular.element($event.target).parent().children().find(".imgCont");
                                //启用上传图片功能
                                var currentUploadInput=angular.element($event.target).parent().children().find(".uploadInput");

                                // 提交评论使用
                                //$scope.parentId = parentId;
                                //console.log($scope.parentId)
                                //$scope.userName = userName;
                                //console.log($scope.userName)
                                //$scope.ParentUserID = ParentUserID;
                                //console.log($scope.ParentUserID)
                                var logUserId = uid_fouNder;
                                console.log("评论用户id")
                                console.log(logUserId)
                                var LogUserName = username_fouNder;
                                var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                                    parentUserID = $scope.ParentUserID, topic = topic, userID = logUserId
                                    , userName = LogUserName, type = 0, content = sendMesg;

                                //提交回复
                                $.ajax({
                                    type: "post",
                                    url: sentComent,
                                    data: {
                                        "siteID": siteID,
                                        "rootID": rootID,
                                        "parentID": parentID,
                                        "parentUser": parentUser,
                                        "parentUserID": parentUserID,
                                        "topic": topic,
                                        "userID": userID,
                                        "userName": userName,
                                        "type": type,
                                        "content": content,
                                        "channel": 0,
                                        "sourceType": source,
                                        "imgUrl":comimgUrl

                                    },
                                    dataType: "json",
                                    //jsonp: "jsoncallback",
                                    //jsoncallback:"jsoncallback",
                                    success: function (data) {

                                        console.log(data);
                                        alert("上传成功");
                                        $scope.getNewCom();
                                        console.log("发送内容为：");
                                        console.log(sendMesg);
                                        $(currInput).val("");
                                        $(pareDiv).addClass('hideInput');
                                        //清空长传的图片
                                        $(currentImgCon).text("");
                                        //启用上传图片功能
                                        $(currentUploadInput).attr("disabled", false);
                                        //清除全局变量图片
                                        window.uploadFile="";

                                    },
                                    error: function () {
                                        alert("图片上传失败");
                                        $("#comInput").val("");
                                        $(pareDiv).addClass('hideInput');
                                    }
                                });
                            },1000);
                        },
                        error: function () {
                            alert("评论失败！2");
                            $("#comInput").val("");
                            $(pareDiv).addClass('hideInput');
                        }
                    });
                }

            };


            //子评论
            $scope.lunchaMorChilCom=true;
            //获取子评论加载更多更多内容 id为每条父评论的id号
            $scope.checkMorChildCom=function (id,index) {
                $scope.lunchaMorChilCom=false;

                $http.jsonp(replayComent+'id='+id+'&page=0&siteId=1&source=0&jsoncallback=JSON_CALLBACK'
                ).success(function(data,header,config,status){
                    //点击查看更多子评论之前
                    $scope.beforLoadMorChid=$scope.commenCon[index].topDiscuss.list;
                    //点击查看更多子评论之后
                    $scope.commenCon[index].topDiscuss.list=data.list;
                    // 是否还有更多评论
                    /*console.log("是否有更多")
                     console.log(data.hasMore)*/
                    $scope.hasNoChildMorCom={};
                    $scope.hasChildMorCom={};
                    if(data.hasMore){
                        $scope.hasChildMorCom.index=true;
                    }else{
                        $scope.hasNoChildMorCom.index=true;

                    }
                    //获取评论
                    // $scope.commenCon=data.list;
                }).error(function(data,header,config,status){
                });
            }

        //文章评论举报点击功能
        $scope.reportCom=function ($event,userName) {
            var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            if($(currInputPar).find(".reportComText").hasClass('hideTextarea')){
                $(currInputPar).find(".reportComText").removeClass("hideTextarea");
            }else{
                $(currInputPar).find(".reportComText").addClass("hideTextarea");
            }

            $(currInputPar).find(".reportComText").find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            $(currInputPar).find(".reportComText").focus();
        };

        //文章回复中的举报 文章子评论中评论举报
        $scope.reportComReplay=function ($event,userName) {
            ////if($rootScope.uid_fouNder){
            //var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
            //console.log("current")
            //console.log(currInputPar)
            //if($(currInputPar).find(".reportComTextReply").hasClass('hideTextarea')){
            //    $(currInputPar).find(".reportComTextReply").removeClass("hideTextarea");
            //}else{
            //    $(currInputPar).find(".reportComTextReply").addClass("hideTextarea");
            //}
            //
            //$(currInputPar).find(".reportComTextReply").find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            //$(currInputPar).find(".reportComTextReply").focus();
            var currInputPar=angular.element($event.target).parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            $(currInputPar).each(function(index,val){
                if(val.className.indexOf('reportComTextReply')!=-1){
                    var cureInput=val;
                    if($(cureInput).hasClass('hideTextarea')){
                        $(cureInput).removeClass("hideTextarea");
                    }else{
                        $(cureInput).addClass("hideTextarea");
                    }
                }
            });

            $(currInputPar).find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            console.log("当前的input")
            console.log($(currInputPar).find("textarea"))
            $(currInputPar).find(".reportComTextReply").focus();

        };

        //文章举报提交
        $scope.par_input_port_send=function($event,id,userName,userID){
            var currInput=angular.element($event.target).parent().parent().parent().parent().children();
            //找到当前文本域，提交后隐藏
            var currPortTextarear=$(currInput).find(".reportComText");
            var replayCurrPortTextarear=$(currInput).find(".reportComTextReply")
            var sendPortMsg=$(currInput).find(".reportComText").find("textarea").val();
            var replaySendPortMsg=$(currInput).find(".reportComTextReply").find("textarea").val();
            console.log(sendPortMsg);
            //siteID = 1,
            var rootID = articleId, userID = userID, userName =userName,
                reason=sendPortMsg;

            //提交回复
            $.ajax({
                type: "post",
                url: sentComentExpose,
                data:{
                    //"siteID":siteID,
                    "rootID": rootID,
                    "userID": userID,
                    "userName": userName,
                    "reason": sendPortMsg
                },
                dataType : "jsonp",
                jsonp: "jsoncallback",
                jsoncallback:"jsoncallback",
                success: function(data){
                        alert("举报成功！");
                        $(currPortTextarear).addClass('hideTextarea');
                        $(replayCurrPortTextarear).addClass('hideTextarea');
                        $(currInput).find(".reportComText").find("textarea").val("");
                        $(replayCurrPortTextarear).find("textarea").val("");
                },
                error: function(){
                    alert("举报失败");
                    $(currPortTextarear).addClass('hideTextarea');
                }
            });
        };

        //文章评论点赞
        $scope.commPraiseAdd=function($event,$index,id){
            var currComPic=angular.element($event.target);
            var userID=uid_fouNder;
            if(!userID){
                userID=0;
            }
            console.log(id)
            console.log("当前点击对象")
            console.log(currComPic)
            var id =id ,type=1,eventType=1, userID = userID,siteID=1,userOtherID='',channel=0;
            $.ajax({
                type: "post",
                url: detailPrasieUrl,
                data:{
                    "id": id,
                    "type": type,
                    "eventType": eventType,
                    "userID": userID,
                    "siteID":siteID,
                    "userOtherID":userOtherID,
                    "channel":channel
                },
                dataType : "jsonp",
                jsonp: "jsoncallback",
                jsoncallback:"jsoncallback",
                success: function(data){
                    $scope.commenCon[$index].countPraise++;
                    $(currComPic[0]).attr("src",'static/thuAc.png');
                },
                error: function(){
                    alert("评论点赞失败");
                }

            });
        };

        ////文章子评论点赞
        //$scope.commPraiseAddChild=function($event,$index,id){
        //    var currComPic=angular.element($event.target).parent().parent();
        //    var userID=uid_fouNder;
        //    if(!userID){
        //        userID=0;
        //    }
        //    console.log(id)
        //    console.log("当前点击对象")
        //    console.log(currComPic)
        //    var id =id ,type=1,eventType=1, userID = userID,siteID=1,userOtherID='',channel=0;
        //    $.ajax({
        //        type: "post",
        //        url: detailPrasieUrl,
        //        data:{
        //            "id": id,
        //            "type": type,
        //            "eventType": eventType,
        //            "userID": userID,
        //            "siteID":siteID,
        //            "userOtherID":userOtherID,
        //            "channel":channel
        //        },
        //        dataType : "jsonp",
        //        jsonp: "jsoncallback",
        //        jsoncallback:"jsoncallback",
        //        success: function(data){
        //            alert("评论点赞成功！");
        //            $scope.commenCon[$index].countPraise++;
        //            $(currComPic[0]).attr("src",'static/thuAc.png')
        //        },
        //        error: function(){
        //            alert("评论点赞失败");
        //        }
        //    });
        //}

    }]);






 /**
     * 活动详情detailActCtr
* */
app.controller('detailActCtr',
    ['$scope','$location','$routeParams','$http','$sce','$rootScope', function ($scope,$location,$routeParams,$http,$sce,$rootScope) {
        //获取视活动详情数据
        var articleId = $routeParams.fileId;
        //loading提示
        $("#globalLoading").css({opacity:'1'});

        //保持高亮方式
        //因为活动没有返回columId号，暂时写为4
        lightIndex=4;
        console.log("articleId");
        console.log(articleId);

        //首次加载隐藏回到顶部按钮
        $(".baToTop").hide();

        //清空活动分享数据
        window.shareUrl='';
        window.shareTitle="";
        window.shareImg="";
        window.shareContent="";
        var shareUrl=$location.absUrl().slice($location.absUrl().indexOf("#")+1);
        window.shareUrl=globalShareUrl+shareUrl;


        //window.shareUrl=

        //活动规则展开功能
        $scope.lunchActList=function(){
            $("#actDetailRul").removeClass('actDetailRulHide');
            $(".lunchImg").css({display:'none'});
        }


        //活动点赞数由列表页传递
        $scope.activeCountPraise=activeCountPraise;

        var topic="";
        // articleId=测试155

            $http.jsonp(DetailActData+'siteID=1&fileId='+articleId+'&jsoncallback=JSON_CALLBACK'
            ).success(function (data) {
                //活动分享标题和内容
                window.shareTitle=data.title;
                window.shareContent=data.attAbstract;
                //活动详情
                $scope.actDetailData = data;
                console.log("活动详情");
                console.log(data.content);
                topic=data.title;//评论使用
                console.log($scope.actDetailData);

                //活动是否关闭该篇稿件评论功能
                if(data== "" || data == undefined ||data == null){
                    $scope.currentDiscussClosed=0;
                }else{
                    $scope.currentDiscussClosed=data.discussClosed;
                }

                var datas=data.content;//获取动态模板
                var indexA=datas.indexOf("<body>");
                var indexB=datas.indexOf("<\/body>");
                var detailDatass=datas.substring((indexA+6) ,indexB);
                //后去除去body标签内容
                $scope.conAct=detailDatass;

                // 非组图图片
                var i=0;
                var reg=/<!--IMAGEARRAY#[0-9]{1,}-->/gi;
                $scope.conAct=$scope.conAct.replace(reg,function () {
                    return '<img src="'+data.images[0].imagearray[i++].imageUrl+'">';
                });

                $scope.trustHtmlAct = $sce.trustAsHtml($scope.conAct);
                if(indexA==-1){
                    $scope.trustHtmlAct = $sce.trustAsHtml(datas);
                }
                if(!$scope.conAct){
                    $scope.hideDetailDiv=true;
                    $scope.hideShowAllArt=true;
                }

                //loading提示
                $("#globalLoading").animate({opacity:'0'},500);
            }).error(function (data, header, config, status) {
            });


        //活动稿件点赞
        $rootScope.detailAddPraseImag="static/13.png";
        $scope.detailAddPrase=function () {
            //if(doGetCookie(articleId)){
            //    alert("请不要重复点赞");
            //    return
            //}else{
                $scope.activeCountPraise++;
                $rootScope.detailAddPraseImag="static/14.png";
                $rootScope.detailAddPraseImagSmall="static/thuAc.png";

                var id=articleId,type=0,eventType=1,channel=0;
                //提交回复
                $.ajax({
                    type: "post",
                    url: detailPrasieUrl,
                    data:{
                        "id": id,
                        "type": type,
                        "eventType": eventType,
                        "channel":channel
                    },
                    dataType : "jsonp",
                    jsonp: "jsoncallback",
                    jsoncallback:"jsoncallback",
                    success: function(data){
                        document.cookie=articleId='true';
                        //$scope.actDetailData.countPraise++;
                    },
                    error: function(){
                         alert("点赞失败");
                    }
                });
            //}
        };
        //活动收藏
        $rootScope.detailAddStorImagSmall="static/18.png";
        $rootScope.detailAddStorImag="static/15.png";
        $scope.detailAddStor=function () {
            if(uid_fouNder){
                var userID=uid_fouNder;
                $rootScope.detailAddStorImagSmall="static/19.png";
                $rootScope.detailAddStorImag="static/16.png";
                var userID=userID,siteID=1,type=0,id=articleId,channel=0;
                //提交回复
                $http.jsonp(artDetailAddStorUrl+'userID='+userID+'&siteID='+siteID+'&type='+type+'&id='+id+'&channel'+channel+'&jsoncallback=JSON_CALLBACK'
                ).success(function(data,header,config,status){
                    console.log("收藏成功");
                }).error(function(data,header,config,status){

                });
            }else{
                alert("请登录后收藏");
                ssologin();
                //$scope.h5Jump('http://59.108.92.239:9081/SSOv2/user/ssoLogin?code=yxapp&redirectUrl=http://59.108.92.239/amucsite/pad/sso/setCookie.html?&anyUrl=http://59.108.92.239/amucsite/pad/index.html#/detail/'+articleId+'&isAppType=app');
            }

        };

        //活动模态框
        $scope.hideMod=function(){
            $('#myModal').modal('hide');
        }
        $scope.actImg='static/23.png'
        //活动报名
        $scope.enlist=function(){
            $('#myModal').modal('show');

        }
        $scope.activeEntryConfirm=function(){
            //用户信息????未填写
            //var userID=$rootScope.userID;
            //var userName=$rootScope.userID;
            //var userImage=$rootScope.userImage;
            var userID='2';
            var userName='ss';
            var userImage='sss';
            var fileId=articleId,siteId= 1;
            var phone=$scope.activPhone;
            var realName=$scope.activName;

            $http.jsonp(activityList+'userID='+userID+'&siteID='+siteId+'&fileId='+fileId+'&userName='+userName+'&userImage'+userImage+'&realName'+realName+'&phone'+phone+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("报名成功");
                $('#myModal').modal('hide');
                $scope.actImg='static/24.png';
            }).error(function(data,header,config,status){

            });
        }

        /**
         * 活动详情评论，与其他评论source=6不同
         * */
        var source=actSource;
        //获取最新评论  page=0开始;加载更多评论
        var compage=0;
        //加载更多最新评论（只有最新评论有分页）id=3969全替换为articleId*****
        $scope.LoadMoreCom=function () {
            compage++;
            $http.jsonp(newComment+'id='+articleId+'&siteId=1&lastFileId=0&page='+compage+'&source='+source+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                // 是否还有更多评论
                $scope.hasMorCom=data.hasMore;
                $scope.commenCon=$scope.commenCon.concat(data.list);
            }).error(function(data,header,config,status){

            });

        };

        //获取最新评论
        $scope.getNewCom=function () {
            $scope.commeInputs=siteConfig.defaultHint;
            //'+articleId+'  '+source+'
            $http.jsonp(newComment+'id='+articleId+'&siteId=1&lastFileId=0&page=0&source='+source+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("第一次最新评论");
                console.log(data);
                // 是否还有更多评论
                $scope.hasMorCom=data.hasMore;
                $scope.commenCon=data.list;
                $scope.totalCount=data.totalCount;
            }).error(function(data,header,config,status){

            });
        };

        //// 加载详情页时先加载最新评论一次，顺序问题,不能放getNewCom方法前
        //$scope.getNewCom();

            //活动首个评论提交输入框
                $scope.sendComFistBtn=function () {
                    console.log(window.uploadFile);
                    //只提交文字
                    if(!window.uploadFile) {
                        var sendMesg = $("#commeInputs").val();
                        console.log("评论信息");
                        console.log(sendMesg);
                        var logUserId = $rootScope.uid_fouNder;
                        console.log("评论用户id")
                        console.log(logUserId);
                        var LogUserName = $rootScope.username_fouNder;
                        //匿名评论
                        if(!uid_fouNder){
                            logUserId=0;
                            LogUserName="pc用户";
                        }

                        var siteID = 1, rootID = articleId, parentID = 0, parentUser = '',
                            parentUserID = 0, topic = topic, userID = logUserId
                            , userName = LogUserName, type = 0, content = sendMesg;

                        //提交回复
                        $.ajax({
                            type: "post",
                            url: sentComent,
                            data: {
                                "siteID": siteID,
                                "rootID": rootID,
                                "parentID": parentID,
                                "parentUser": parentUser,
                                "parentUserID": parentUserID,
                                "topic": topic,
                                "userID": userID,
                                "userName": userName,
                                "type": type,
                                "content": content,
                                "channel": 0,
                                "sourceType": source
                            },
                            dataType: "json",
                            //jsonp: "jsoncallback",
                            //jsoncallback:"jsoncallback",
                            success: function (data) {
                                if (data) {
                                    console.log(data);
                                    alert("评论成功！");
                                    $scope.getNewCom();
                                    console.log("发送内容为：");
                                    console.log(sendMesg);
                                    $("#commeInputs").val("");
                                } else {
                                    alert("评论失败！1");
                                }
                            },
                            error: function () {
                                alert("评论失败！2");
                                $("#commeInputs").val("");
                            }
                        });
                    }else{
                        //活动上传图片和文字的评论
                        //图片提交
                        var uploadFile=window.uploadFile;
                        console.log(window.uploadFile);
                        var formdata = new FormData();
                        formdata.append("Filedata", uploadFile);
                        formdata.append("siteID", 1);
                        formdata.append("location", 0);
                        formdata.append("userId", "0");
                        formdata.append("fileType", "picture");
                        formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                        $.ajax({
                            type:'POST',
                            url: commUpload,
                            processData: false,
                            data: formdata,
                            async:false,
                            contentType: false,    //这个一定要写
                            dataType:'json',
                            success: function(result){
                                //成功后处理代码
                                //self.onSuccess(file, result);
                                //if(self.curUploadFile.length==0){
                                // 回调全部完成方法
                                //self.onComplete("全部完成");
                                console.log("result");
                                console.log(result)
                                console.log("上传成功url");
                                var comimgUrl=JSON.parse(result).fileList[0].url;
                                console.log(comimgUrl);
                                setTimeout(function(){
                                    var sendMesg = $("#commeInputs").val();
                                    console.log("评论信息");
                                    console.log(sendMesg);
                                    var logUserId = $rootScope.uid_fouNder;
                                    console.log("评论用户id")
                                    console.log(logUserId)
                                    //匿名评论
                                    if(!uid_fouNder){
                                        logUserId=0;
                                        LogUserName="pc用户";
                                    }
                                    var LogUserName = $rootScope.username_fouNder;
                                    var siteID = 1, rootID = articleId, parentID = 0, parentUser = '',
                                        parentUserID = 0, topic = topic, userID = logUserId
                                        , userName = LogUserName, type = 0, content = sendMesg;

                                    //提交回复
                                    $.ajax({
                                        type: "post",
                                        url: sentComent,
                                        data: {
                                            "siteID": siteID,
                                            "rootID": rootID,
                                            "parentID": parentID,
                                            "parentUser": parentUser,
                                            "parentUserID": parentUserID,
                                            "topic": topic,
                                            "userID": userID,
                                            "userName": userName,
                                            "type": type,
                                            "content": content,
                                            "channel": 0,
                                            "sourceType": source,
                                            "imgUrl":comimgUrl
                                        },
                                        dataType: "json",
                                        //jsonp: "jsoncallback",
                                        //jsoncallback:"jsoncallback",
                                        success: function (data) {
                                            console.log(data);
                                            alert("评论图片上传成功！");
                                            $scope.getNewCom();
                                            //图片上传成功后，清除当前图片，设置可以重新添加上传图片
                                            $('.img-cont').text("");
                                            $("#file").attr("disabled", false);
                                            //清除全局变量图片
                                            window.uploadFile="";

                                        },
                                        error: function () {
                                            alert("评论失败！");
                                            $("#commeInputs").val("");
                                        }
                                    });
                                },1000)

                            },
                            error: function(){
                                self.onFailure(file);
                            }

                        });

                    }
                };



        //获取 热门评论 id = '+articleId+'??
        $scope.getHotCom=function () {
            $http.jsonp(hotComment+'id='+articleId+'&siteId=1&source='+source+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log(data);
                // 是否还有更多评论
                $scope.hasMorCom=data.hasMore;
                //获取评论
                $scope.commenCon=data.list;
            }).error(function(data,header,config,status){
            });
        };


        //活动类型获取全局配置信息
        $scope.getCommentInfo=function(){
            $http.jsonp(commInfo+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("全局评论信息");
                console.log(data);
                $scope.siteConfig=data.siteConfig.discuss;
                //评论框提示语
                siteConfig.defaultHint=$scope.siteConfig.defaultHint;
                //官方评论用户名
                siteConfig.defaultName=$scope.siteConfig.defaultName;
                $scope.defaultName=$scope.siteConfig.defaultName;
                //官方评论头像
                siteConfig.defaultIcon=$scope.siteConfig.defaultIcon;
                $scope.siteConfigDefaultIcon=$scope.siteConfig.defaultIcon;
                console.log("官方用户名");
                console.log($scope.defaultName);
                //是否关闭全站评论功能
                $scope.siteConfigAuditType=$scope.siteConfig.auditType;
                //全局评论颜色问题
                $scope.commStyleColor=$scope.siteConfig.styleColor;
                commentStyle=$scope.commStyleColor;
                $rootScope.changeComStyle();

                //获取最新和热门评论
                $scope.getNewCom();
                //setTimeout(function () {

                //},1000)
            }).error(function(data,header,config,status){

            });

        };
        $scope.getCommentInfo();


        //活动回复点击功能
        $scope.replayCom=function ($event,userName) {
            var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            $(currInputPar).each(function(index,val){
                if(val.className.indexOf('comm_con_input_par')!=-1){
                    var cureInput=val;
                    if($(cureInput).hasClass('hideInput')){
                        $(cureInput).removeClass("hideInput");
                    }else{
                        $(cureInput).addClass("hideInput");
                    }
                }
            })

            var currInput= $(currInputPar[3]).find("input");
            $(currInput).attr("placeholder","@"+userName+":");
            $(currInput).focus();
        };

        //活动父评论的提交，和上传图片
        $scope.par_input_send=function ($event,parentId,userName,ParentUserID) {
            var currInput=angular.element($event.target).parent().parent().find("input");
            console.log($(currInput).val());
            var sendMesg=$(currInput).val();
            console.log("用户一级评论内容");
            console.log(sendMesg);
            if(!window.uploadFile) {
                //只提交文字
                var pareDiv = angular.element($event.target).parent().parent();
                // 提交评论使用
                $scope.parentId = parentId;
                console.log($scope.parentId)
                $scope.userName = userName;
                console.log($scope.userName)
                $scope.ParentUserID = ParentUserID;
                console.log($scope.ParentUserID)
                var logUserId = uid_fouNder;
                console.log("评论用户id")
                console.log(logUserId)
                var LogUserName = username_fouNder;
                var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                    parentUserID = $scope.ParentUserID, topic = topic, userID = logUserId
                    , userName = LogUserName, type = 0, content = sendMesg;

                //提交回复
                $.ajax({
                    type: "post",
                    url: sentComent,
                    data: {
                        "siteID": siteID,
                        "rootID": rootID,
                        "parentID": parentID,
                        "parentUser": parentUser,
                        "parentUserID": parentUserID,
                        "topic": topic,
                        "userID": userID,
                        "userName": userName,
                        "type": type,
                        "content": content,
                        "channel": 0,
                        "sourceType": source
                    },
                    dataType: "json",
                    //jsonp: "jsoncallback",
                    //jsoncallback:"jsoncallback",
                    success: function (data) {
                        if (data) {
                            console.log(data);
                            alert("评论成功！");
                            $scope.getNewCom();
                            console.log("发送内容为：");
                            console.log(sendMesg);
                            $(currInput).val("");
                            $(pareDiv).addClass('hideInput');
                        } else {
                            alert("评论失败！1");
                        }

                    },
                    error: function () {
                        alert("评论失败！2");
                        $("#comInput").val("");
                        $(pareDiv).addClass('hideInput');
                    }
                });
            }else{
                //既有图片又有文字的评论回复
                //图片提交
                var uploadFile=window.uploadFile;
                console.log(window.uploadFile);
                var formdata = new FormData();
                formdata.append("Filedata", uploadFile);
                formdata.append("siteID", 1);
                formdata.append("location", 0);
                formdata.append("userId", "0");
                formdata.append("fileType", "picture");
                formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                $.ajax({
                    type:'POST',
                    url: commUpload,
                    processData: false,
                    data: formdata,
                    async:false,
                    contentType: false,    //这个一定要写
                    dataType:'json',
                    success: function(result) {
                        //成功后处理代码
                        //self.onSuccess(file, result);
                        //if(self.curUploadFile.length==0){
                        // 回调全部完成方法
                        //self.onComplete("全部完成");
                        console.log("result");
                        console.log(result)
                        console.log("上传成功url");
                        var comimgUrl = JSON.parse(result).fileList[0].url;
                        console.log(comimgUrl);
                        //获取图片url后再调用接口
                        setTimeout(function(){
                            var pareDiv = angular.element($event.target).parent().parent();
                            //清空上传的图片内容
                            var currentImgCon=angular.element($event.target).parent().children().find(".imgCont");
                            console.log(currentImgCon)

                            //启用上传图片功能
                            var currentUploadInput=angular.element($event.target).parent().children().find(".uploadInput");
                            console.log(currentUploadInput)
                            // 提交评论使用
                            $scope.parentId = parentId;
                            console.log($scope.parentId)
                            $scope.userName = userName;
                            console.log($scope.userName)
                            $scope.ParentUserID = ParentUserID;
                            console.log($scope.ParentUserID)
                            var logUserId = uid_fouNder;
                            console.log("评论用户id")
                            console.log(logUserId)
                            var LogUserName = username_fouNder;
                            var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                                parentUserID = $scope.ParentUserID, topic = topic, userID = logUserId
                                , userName = LogUserName, type = 0, content = sendMesg;

                            //提交回复
                            $.ajax({
                                type: "post",
                                url: sentComent,
                                data: {
                                    "siteID": siteID,
                                    "rootID": rootID,
                                    "parentID": parentID,
                                    "parentUser": parentUser,
                                    "parentUserID": parentUserID,
                                    "topic": topic,
                                    "userID": userID,
                                    "userName": userName,
                                    "type": type,
                                    "content": content,
                                    "channel": 0,
                                    "sourceType": source,
                                    "imgUrl":comimgUrl
                                },
                                dataType: "json",
                                //jsonp: "jsoncallback",
                                //jsoncallback:"jsoncallback",
                                success: function (data) {
                                    if (data) {
                                        console.log(data);
                                        alert("评论成功！");
                                        $scope.getNewCom();
                                        console.log("发送内容为：");
                                        console.log(sendMesg);
                                        $(currInput).val("");
                                        $(pareDiv).addClass('hideInput');
                                        $(pareDiv).addClass('hideInput');
                                        //清空长传的图片
                                        $(currentImgCon).text("");
                                        //启用上传图片功能
                                        $(currentUploadInput).attr("disabled", false);
                                        //清除全局变量图片
                                        window.uploadFile="";

                                    } else {
                                        alert("评论失败！1");
                                    }

                                },
                                error: function () {
                                    alert("评论失败！2");
                                    $("#comInput").val("");
                                    $(pareDiv).addClass('hideInput');
                                }
                            });
                        },1000);

                    },
                    error: function () {
                        alert("评论失败！2");
                        $("#comInput").val("");
                        $(pareDiv).addClass('hideInput');
                    }
                });
            }

        };


        //子评论
        $scope.lunchaMorChilCom=true;
        //获取子评论加载更多更多内容 id为每条父评论的id号
        $scope.checkMorChildCom=function (id,index) {
            $scope.lunchaMorChilCom=false;

            $http.jsonp(replayComent+'id='+id+'&page=0&siteId=1&source=0&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                //点击查看更多子评论之前
                $scope.beforLoadMorChid=$scope.commenCon[index].topDiscuss.list;
                //点击查看更多子评论之后
                $scope.commenCon[index].topDiscuss.list=data.list;
                // 是否还有更多评论
                /*console.log("是否有更多")
                 console.log(data.hasMore)*/
                $scope.hasNoChildMorCom={};
                $scope.hasChildMorCom={};
                if(data.hasMore){
                    $scope.hasChildMorCom.index=true;
                }else{
                    $scope.hasNoChildMorCom.index=true;

                }
                //获取评论
                // $scope.commenCon=data.list;
            }).error(function(data,header,config,status){
            });
        }

        //活动评论举报
        //parent评论内容中的回复
        $scope.reportCom=function ($event,userName) {
            //if($rootScope.uid_fouNder){
            var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            if($(currInputPar).find(".reportComText").hasClass('hideTextarea')){
                $(currInputPar).find(".reportComText").removeClass("hideTextarea");
            }else{
                $(currInputPar).find(".reportComText").addClass("hideTextarea");
            }
            $(currInputPar).find(".reportComText").find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            $(currInputPar).find(".reportComText").focus();
            //}else{
            //    alert("请登录后再回复");
            //}
        };

        //活动评论举报提交
        $scope.par_input_port_send=function($event,id,userName,userID){
            var currInput=angular.element($event.target).parent().parent().parent().parent().children();
            var currPortTextarear=$(currInput).find(".reportComText")
            var sendPortMsg=$(currInput).find(".reportComText").find("textarea").val();
            console.log(sendPortMsg);
            var  rootID = articleId, userID = userID, userName =userName,
                reason=sendPortMsg;

            //提交回复
            $.ajax({
                type: "post",
                url: sentComentExpose,
                data:{
                    //"siteID":siteID,
                    "rootID": rootID,
                    "userID": userID,
                    "userName": userName,
                    "reason": sendPortMsg
                },
                dataType : "jsonp",
                jsonp: "jsoncallback",
                jsoncallback:"jsoncallback",
                success: function(data){
                    alert("举报成功！");
                    $(currPortTextarear).addClass('hideTextarea');
                    $(currInput).find(".reportComText").find("textarea").val("");
                },
                error: function(){
                    alert("举报失败");
                    $(currPortTextarear).addClass('hideTextarea');
                }
            });
        }

        //活动回复中的举报 活动子评论中评论举报
        $scope.reportComReplay=function ($event,userName) {
            var currInputPar=angular.element($event.target).parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            $(currInputPar).each(function(index,val){
                if(val.className.indexOf('reportComTextReply')!=-1){
                    var cureInput=val;
                    if($(cureInput).hasClass('hideTextarea')){
                        $(cureInput).removeClass("hideTextarea");
                    }else{
                        $(cureInput).addClass("hideTextarea");
                    }
                }
            });

            $(currInputPar).find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            console.log("当前的input")
            console.log($(currInputPar).find("textarea"))
            $(currInputPar).find(".reportComTextReply").focus();

        };

        //活动评论点赞
        $scope.commPraiseAdd=function($event,$index,id){
            var currComPic=angular.element($event.target);
            var userID=uid_fouNder;
            if(!userID){
                userID=0;
            }
            console.log(id)
            console.log("当前点击对象")
            console.log(currComPic)
            var id =id ,type=1,eventType=1, userID = userID,siteID=1,userOtherID='',channel=0;
            $.ajax({
                type: "post",
                url: detailPrasieUrl,
                data:{
                    "id": id,
                    "type": type,
                    "eventType": eventType,
                    "userID": userID,
                    "siteID":siteID,
                    "userOtherID":userOtherID,
                    "channel":channel
                },
                dataType : "jsonp",
                jsonp: "jsoncallback",
                jsoncallback:"jsoncallback",
                success: function(data){
                    $scope.commenCon[$index].countPraise++;
                    $(currComPic[0]).attr("src",'static/thuAc.png');
                },
                error: function(){
                    alert("评论点赞失败");
                }

            });
        };

    }])





/**
 * 直播详情
 * */
app.controller('detailLiveCtrl',
    ['$scope','$location','$routeParams','$http','$sce','$rootScope', function ($scope,$location,$routeParams,$http,$sce,$rootScope) {
        //loading提示
        $("#globalLoading").css({opacity:'1'});
        //获取详情信息
        $scope.sceControl = $sce.trustAsResourceUrl;
        var linkId=$routeParams.linkID;
        var fileId=$routeParams.fileId;
        var articleId=fileId;

        //首次加载隐藏回到顶部按钮
        $(".baToTop").hide();

        //清空直播分享数据
        window.shareUrl='';
        window.shareTitle="";
        window.shareImg="";
        window.shareContent="";
        var shareUrl=$location.absUrl().slice($location.absUrl().indexOf("#")+1);
        window.shareUrl=globalShareUrl+shareUrl;

        var publicArr=[];
        var json = {};
        //id=74 直播详情数据id=上级的linkId
        //原请求地址 liveDetailData+'index=0&id='+linkId+'&start=0&count=20&lastFileId=0&la=40.047023&lo=116.313423&jsoncallback=JSON_CALLBACK'
        $http.jsonp(liveDetailData+'sindex=0&id='+linkId+'&lastFileId=0&page=0&jsoncallback=JSON_CALLBACK'
        ).success(function(data,header,config,status){
            //直播分享标题和内容
            window.shareTitle=data.main.title;
            window.shareContent=data.main.content;

            $scope.liveDetail=data;
            $scope.liveDetailArray=data.list;

            //loading提示
            $("#globalLoading").animate({opacity:'0'},500);

            if($scope.liveDetailArray.length!=0){
                $scope.lastFileId=$scope.liveDetailArray[$scope.liveDetailArray.length-1].fileId;
            }
            $scope.liveDataiPage=0;
            //所有直播流对象，判断如果vedio中没有对象就是图文直播
            $scope.liveImgOrVedioObj=data.main.config.videos;
            if($scope.liveDetail.main.config.videos.length>0){
                console.log("直播url")
                console.log($scope.liveImgOrVedioObj[0].webLiveUrl)
                // liveAllUrl=$scope.liveDetail.main.config.videos;
                window.liveAllUrl.push({"webLiveUrl":$scope.liveImgOrVedioObj[0].webLiveUrl,"streamID":$scope.liveImgOrVedioObj[0].streamID,"webPlaybackUrl":$scope.liveImgOrVedioObj[0].webPlaybackUrl});
                console.log("直播流ssssurl");
                console.log(liveAllUrl[0].webLiveUrl);
            }
            console.log("详情")
            console.log($scope.liveDetail)
            //是否关闭该篇稿件评论功能
            $scope.currentDiscussClosed=data.main.discussClosed;

            if(data.list.length>=20){
                $scope.loadDetailMoreButtonOne=true;
            }else{
                $scope.noDetailLoadMoreButton=true;
            }
            for(var i=0;i<data.list.length;i++){
                var value=data.list[i].publishtime;
                // console.log("时间数组")
                // console.log(value)
                var indexSpac=value.indexOf(" ");
                var lastHourString=value.substring(0,indexSpac);
                if(!json[lastHourString]){
                    publicArr.push(lastHourString);
                    json[lastHourString] = 1;
                }
            }
            console.log("时间数组")
            console.log(publicArr);
            $scope.publicArr=publicArr;

            //直播状态
            $scope.liveDetailStatus=$scope.liveDetail.main.status;
            //直播预告开始时间
            $scope.liveDetailStartTime=$scope.liveDetail.main.startTime;

            if(data.main.status==1){
                //直播流状态
                var stream=liveAllUrl[0].streamID;
                console.log("stream")
                console.log(stream)
                $scope.streamCurrentStatus=data.currentStatus[stream];
                //alert($scope.streamCurrentStatus);

            }else if(data.main.status==2){
                //有无精彩回放
                var webPlaybackUrl=data.main.config.videos[0].webPlaybackUrl;
                console.log("直播回放流")
                console.log(webPlaybackUrl)
                $scope.webPlaybackUrl=data.main.config.videos[0].webPlaybackUrl;
                window.liveAllUrl=[];
                window.liveAllUrl.push({"webLiveUrl":webPlaybackUrl,"streamID":'',"webPlaybackUrl":''});
            }

            //是否有直播
            if($scope.liveImgOrVedioObj.length>0){
                var option = {
                    "live_url":liveAllUrl[0],
                    "width" : 480,
                    "height" : 320
                    //...可选填其他属性
                };

                var player = new qcVideo.Player("id_video_container", option);

            }



        }).error(function(data,header,config,status){
        });

        //直播参与人点赞数
        $http.jsonp(liveCounts+'id=1696&source=1&jsoncallback=JSON_CALLBACK'
        ).success(function(data){
            console.log("新评论点赞数");
            console.log(data);
            $scope.liveCountClick=data.countClick

        }).error(function(data){

        });

        //直播线路切换问题
        $scope.chanLivePath=function(arg){
            window.liveAllUrl[0]=$scope.liveImgOrVedioObj[arg].webLiveUrl;
            console.log(window.liveAllUrl[0]);
        };
        // })

        // })

        /**
         * 详情加载更多
         * */
        $scope.loadMorLiveDetail=function () {
            //loading提示
            $("#globalLoading").css({
                opacity:'1'
            });
            $scope.liveDataiPage++;
            $http.jsonp(liveDetailData+'sindex=0&id='+linkId+'&lastFileId='+$scope.lastFileId+'&page='+$scope.liveDataiPage+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                $scope.liveDetail=data;
                $scope.liveDetailArray=$scope.liveDetailArray.concat(data.list);
                console.log("加载更多数据")
                console.log($scope.liveDetailArray)
                //所有直播流对象，判断如果vedio中没有对象就是图文直播
                // $scope.liveImgOrVedioObj=data.main.config.videos;
                // if($scope.liveDetail.main.config.videos.length>0){
                //     console.log("加载更多直播url")
                //     console.log($scope.liveImgOrVedioObj[0].webLiveUrl)
                // }
                console.log("详情加载更多")
                console.log($scope.liveDetail)
                if(data.list.length>=20){
                    $scope.loadDetailMoreButtonOne=true;
                }else{
                    $scope.loadDetailMoreButtonOne=false;
                    $scope.noDetailLoadMoreButton=true;
                }
                for(var i=0;i<data.list.length;i++){
                    var value=data.list[i].publishtime;
                    // console.log("时间数组")
                    // console.log(value)
                    var indexSpac=value.indexOf(" ");
                    var lastHourString=value.substring(0,indexSpac);
                    if(!json[lastHourString]){
                        publicArr.push(lastHourString);
                        json[lastHourString] = 1;
                    }
                }
                console.log("加载更多时间数组")
                console.log(publicArr);
                $scope.publicArr=publicArr;

                //loading提示
                $("#globalLoading").animate({
                    opacity:'0'
                },500);
            }).error(function(data,header,config,status){
            });
        };


        /**
         * 直播详情评论，与其他评论source=1不同
         * */
        var source=liveSource;
        //获取最新评论  page=0开始;加载更多评论
        var compage=0;
        //加载更多最新评论（只有最新评论有分页）id=3969全替换为articleId*****
        $scope.LoadMoreCom=function () {
            compage++;
            $http.jsonp(newComment+'id='+linkId+'&siteId=1&lastFileId=0&page='+compage+'&source='+source+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                // 是否还有更多评论
                $scope.hasMorCom=data.hasMore;
                $scope.commenCon=$scope.commenCon.concat(data.list);
            }).error(function(data,header,config,status){

            });

        };

        //获取最新评论
        $scope.getNewCom=function () {
            $scope.commeInputs=siteConfig.defaultHint;
            //'+articleId+'  '+source+'
            $http.jsonp(newComment+'id='+linkId+'&siteId=1&lastFileId=0&page=0&source='+source+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("第一次最新评论");
                console.log(data);
                // 是否还有更多评论
                $scope.hasMorCom=data.hasMore;
                $scope.commenCon=data.list;
                $scope.totalCount=data.totalCount;
            }).error(function(data,header,config,status){

            });
        };

        //// 加载详情页时先加载最新评论一次，顺序问题,不能放getNewCom方法前
        //$scope.getNewCom();

        //直播类型获取全局配置信息
        $scope.getCommentInfo=function(){
            $http.jsonp(commInfo+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                console.log("全局评论信息");
                console.log(data);
                $scope.siteConfig=data.siteConfig.discuss;
                //评论框提示语
                siteConfig.defaultHint=$scope.siteConfig.defaultHint;
                //官方评论用户名
                siteConfig.defaultName=$scope.siteConfig.defaultName;
                $scope.defaultName=$scope.siteConfig.defaultName;
                //官方评论头像
                siteConfig.defaultIcon=$scope.siteConfig.defaultIcon;
                $scope.siteConfigDefaultIcon=$scope.siteConfig.defaultIcon;
                console.log("官方用户名");
                console.log($scope.defaultName);
                //是否关闭全站评论功能
                $scope.siteConfigAuditType=$scope.siteConfig.auditType;
                //全局评论颜色问题
                $scope.commStyleColor=$scope.siteConfig.styleColor;
                commentStyle=$scope.commStyleColor;
                $rootScope.changeComStyle();
                //获取最新和热门评论
                $scope.getNewCom();
                //setTimeout(function () {

                //},1000)
            }).error(function(data,header,config,status){

            });

        };
        $scope.getCommentInfo();


        //直播首个评论输入框
         $scope.sendComFistBtn=function () {
                    console.log(window.uploadFile);
                    //直播评论只提交文字
                    if(!window.uploadFile) {
                        var sendMesg = $("#commeInputs").val();
                        console.log("评论信息");
                        console.log(sendMesg);
                        var logUserId = uid_fouNder;
                        console.log("评论用户id")
                        console.log(logUserId)
                        var LogUserName = username_fouNder;
                        //匿名评论
                        if(!uid_fouNder){
                            logUserId=0;
                            LogUserName="pc用户";
                        }

                        var siteID = 1, rootID = linkId, parentID = 0, parentUser = '',
                            parentUserID = 0, topic = topic, userID = logUserId
                            , userName = LogUserName, type = 0, content = sendMesg;

                        //提交回复
                        $.ajax({
                            type: "post",
                            url: sentComent,
                            data: {
                                "siteID": siteID,
                                "rootID": rootID,
                                "parentID": parentID,
                                "parentUser": parentUser,
                                "parentUserID": parentUserID,
                                "topic": topic,
                                "userID": userID,
                                "userName": userName,
                                "type": type,
                                "content": content,
                                "channel": 0,
                                "sourceType": source
                            },
                            dataType: "json",
                            //jsonp: "jsoncallback",
                            //jsoncallback:"jsoncallback",
                            success: function (data) {
                                if (data) {
                                    console.log(data);
                                    alert("评论成功！");
                                    $scope.getNewCom();
                                    console.log("发送内容为：");
                                    console.log(sendMesg);
                                    $("#commeInputs").val("");
                                } else {
                                    alert("评论失败！1");
                                }
                            },
                            error: function () {
                                alert("评论失败！2");
                                $("#commeInputs").val("");
                            }
                        });
                    }else{
                        //直播评论提交图片和文字
                        //图片提交
                        var uploadFile=window.uploadFile;
                        console.log(window.uploadFile);
                        var formdata = new FormData();
                        formdata.append("Filedata", uploadFile);
                        formdata.append("siteID", 1);
                        formdata.append("location", 0);
                        formdata.append("userId", "0");
                        formdata.append("fileType", "picture");
                        formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                        $.ajax({
                            type:'POST',
                            url: commUpload,
                            processData: false,
                            data: formdata,
                            async:false,
                            contentType: false,    //这个一定要写
                            dataType:'json',
                            success: function(result){
                                //成功后处理代码
                                //self.onSuccess(file, result);
                                //if(self.curUploadFile.length==0){
                                // 回调全部完成方法
                                //self.onComplete("全部完成");
                                console.log("result");
                                console.log(result)
                                console.log("上传成功url");
                                var comimgUrl=JSON.parse(result).fileList[0].url;
                                console.log(comimgUrl);
                                setTimeout(function(){
                                    var sendMesg = $("#commeInputs").val();
                                    console.log("评论信息");
                                    console.log(sendMesg);
                                    var logUserId = uid_fouNder;
                                    console.log("评论用户id")
                                    console.log(logUserId)
                                    var LogUserName = username_fouNder;
                                    //匿名评论
                                    if(!uid_fouNder){
                                        logUserId=0;
                                        LogUserName="pc用户";
                                    }
                                    var siteID = 1, rootID = linkId, parentID = 0, parentUser = '',
                                        parentUserID = 0, topic = topic, userID = logUserId
                                        , userName = LogUserName, type = 0, content = sendMesg;

                                    //提交回复
                                    $.ajax({
                                        type: "post",
                                        url: sentComent,
                                        data: {
                                            "siteID": siteID,
                                            "rootID": rootID,
                                            "parentID": parentID,
                                            "parentUser": parentUser,
                                            "parentUserID": parentUserID,
                                            "topic": topic,
                                            "userID": userID,
                                            "userName": userName,
                                            "type": type,
                                            "content": content,
                                            "channel": 0,
                                            "sourceType": source,
                                            "imgUrl":comimgUrl
                                        },
                                        dataType: "json",
                                        //jsonp: "jsoncallback",
                                        //jsoncallback:"jsoncallback",
                                        success: function (data) {
                                            console.log(data);
                                            alert("评论图片上传成功！");
                                            $scope.getNewCom();
                                            //图片上传成功后，清除当前图片，设置可以重新添加上传图片
                                            $('.img-cont').text("");
                                            $("#file").attr("disabled", false);
                                            //清除全局变量图片
                                            window.uploadFile="";
                                        },
                                        error: function () {
                                            alert("评论失败！2");
                                            $("#commeInputs").val("");
                                        }
                                    });
                                },2000)
                            },
                            error: function(){
                                self.onFailure(file);
                            }

                        });

                    }
                };


        //直播点击回复评论功能
        $scope.replayCom=function ($event,userName) {
            var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            $(currInputPar).each(function(index,val){
                if(val.className.indexOf('comm_con_input_par')!=-1){
                    var cureInput=val;
                    if($(cureInput).hasClass('hideInput')){
                        $(cureInput).removeClass("hideInput");
                    }else{
                        $(cureInput).addClass("hideInput");
                    }
                }
            })

            var currInput= $(currInputPar[4]).find("input");
            $(currInput).attr("placeholder","@"+userName+":");
            $(currInput).focus();
        };
        //直播评论提交和上传图片
        $scope.par_input_send=function ($event,parentId,userName,ParentUserID) {
            var currInput=angular.element($event.target).parent().parent().find("input");
            console.log($(currInput).val());
            var sendMesg=$(currInput).val();
            console.log("用户一级评论内容");
            console.log(sendMesg);
            if(!window.uploadFile) {
                //只提交文字
                var pareDiv=angular.element($event.target).parent().parent();
                // 提交评论使用
                $scope.parentId=parentId;
                console.log($scope.parentId)
                $scope.userName=userName;
                console.log($scope.userName)
                $scope.ParentUserID=ParentUserID;
                console.log($scope.ParentUserID)
                var logUserId=uid_fouNder;
                console.log("评论用户id")
                console.log(logUserId)
                var LogUserName=username_fouNder;
                var siteID = 1, rootID = linkId, parentID = $scope.parentId, parentUser = $scope.userName,
                    parentUserID = $scope.ParentUserID, topic =topic, userID = logUserId
                    , userName = LogUserName, type = 0,content=sendMesg;

                //提交回复
                $.ajax({
                    type: "post",
                    url: sentComent,
                    data:{
                        "siteID":siteID,
                        "rootID": rootID,
                        "parentID": parentID,
                        "parentUser": parentUser,
                        "parentUserID": parentUserID,
                        "topic": topic,
                        "userID": userID,
                        "userName": userName,
                        "type": type,
                        "content":content,
                        "channel":0,
                        "sourceType":source
                    },
                    dataType : "json",
                    //jsonp: "jsoncallback",
                    //jsoncallback:"jsoncallback",
                    success: function(data){
                        if(data){
                            console.log(data);
                            alert("评论成功！");
                            $scope.getNewCom();
                            console.log("发送内容为：");
                            console.log(sendMesg);
                            $(currInput).val("");
                            $(pareDiv).addClass('hideInput');
                        }else{
                            alert("评论失败！1");
                        }

                    },
                    error: function(){
                        alert("评论失败！2");
                        $("#comInput").val("");
                        $(pareDiv).addClass('hideInput');
                    }
                });
            }else{
                //既有图片又有文字的评论回复
                //图片提交
                var uploadFile=window.uploadFile;
                console.log(window.uploadFile);
                var formdata = new FormData();
                formdata.append("Filedata", uploadFile);
                formdata.append("siteID", 1);
                formdata.append("location", 0);
                formdata.append("userId", "0");
                formdata.append("fileType", "picture");
                formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                $.ajax({
                    type:'POST',
                    url: commUpload,
                    processData: false,
                    data: formdata,
                    async:false,
                    contentType: false,    //这个一定要写
                    dataType:'json',
                    success: function(result) {
                        console.log("result");
                        console.log(result)
                        console.log("上传成功url");
                        var comimgUrl = JSON.parse(result).fileList[0].url;
                        console.log(comimgUrl);
                        //获取图片url后再调用接口
                        setTimeout(function(){
                            var pareDiv=angular.element($event.target).parent().parent();
                            //清空上传的图片内容
                            var currentImgCon=angular.element($event.target).parent().children().find(".imgCont");
                            //启用上传图片功能
                            var currentUploadInput=angular.element($event.target).parent().children().find(".uploadInput");
                            // 提交评论使用
                            $scope.parentId=parentId;
                            console.log($scope.parentId)
                            $scope.userName=userName;
                            console.log($scope.userName)
                            $scope.ParentUserID=ParentUserID;
                            console.log($scope.ParentUserID)
                            var logUserId=uid_fouNder;
                            console.log("评论用户id")
                            console.log(logUserId)
                            var LogUserName=username_fouNder;
                            var siteID = 1, rootID = linkId, parentID = $scope.parentId, parentUser = $scope.userName,
                                parentUserID = $scope.ParentUserID, topic =topic, userID = logUserId
                                , userName = LogUserName, type = 0,content=sendMesg;

                            //提交回复
                            $.ajax({
                                type: "post",
                                url: sentComent,
                                data:{
                                    "siteID":siteID,
                                    "rootID": rootID,
                                    "parentID": parentID,
                                    "parentUser": parentUser,
                                    "parentUserID": parentUserID,
                                    "topic": topic,
                                    "userID": userID,
                                    "userName": userName,
                                    "type": type,
                                    "content":content,
                                    "channel":0,
                                    "sourceType":source,
                                    "imgUrl":comimgUrl
                                },
                                dataType : "json",
                                //jsonp: "jsoncallback",
                                //jsoncallback:"jsoncallback",
                                success: function(data){
                                        console.log(data);
                                        alert("评论成功！");
                                        $scope.getNewCom();
                                        console.log("发送内容为：");
                                        console.log(sendMesg);
                                        $(currInput).val("");
                                        $(pareDiv).addClass('hideInput');
                                        //清空长传的图片
                                        $(currentImgCon).text("");
                                        //启用上传图片功能
                                        $(currentUploadInput).attr("disabled", false);
                                        //清除全局变量图片
                                        window.uploadFile="";

                                },
                                error: function(){
                                    alert("评论失败！2");
                                    $("#comInput").val("");
                                    $(pareDiv).addClass('hideInput');
                                }
                            });
                        },1000);
                    },
                    error: function () {
                        alert("评论失败！2");
                        $("#comInput").val("");
                        $(pareDiv).addClass('hideInput');
                    }
                });
            }

        };

        //子评论
        $scope.lunchaMorChilCom=true;
        //获取子评论加载更多更多内容 id为每条父评论的id号
        $scope.checkMorChildCom=function (id,index) {
            $scope.lunchaMorChilCom=false;

            $http.jsonp(replayComent+'id='+id+'&page=0&siteId=1&source=0&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                //点击查看更多子评论之前
                $scope.beforLoadMorChid=$scope.commenCon[index].topDiscuss.list;
                //点击查看更多子评论之后
                $scope.commenCon[index].topDiscuss.list=data.list;
                // 是否还有更多评论
                /*console.log("是否有更多")
                 console.log(data.hasMore)*/
                $scope.hasNoChildMorCom={};
                $scope.hasChildMorCom={};
                if(data.hasMore){
                    $scope.hasChildMorCom.index=true;
                }else{
                    $scope.hasNoChildMorCom.index=true;

                }
                //获取评论
                // $scope.commenCon=data.list;
            }).error(function(data,header,config,status){
            });
        };

        //直播评论举报
        //parent评论内容中的回复
        $scope.reportCom=function ($event,userName) {
            //if($rootScope.uid_fouNder){
            var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            if($(currInputPar).find(".reportComText").hasClass('hideTextarea')){
                $(currInputPar).find(".reportComText").removeClass("hideTextarea");
            }else{
                $(currInputPar).find(".reportComText").addClass("hideTextarea");
            }
            $(currInputPar).find(".reportComText").find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            $(currInputPar).find(".reportComText").focus();
            //}else{
            //    alert("请登录后再回复");
            //}
        };

        //直播举报提交
        $scope.par_input_port_send=function($event,id,userName,userID){
            var currInput=angular.element($event.target).parent().parent().parent().parent().children();
            var currPortTextarear=$(currInput).find(".reportComText");
            var currPortTextarearOther=$(currInput).parent().find(".reportComTextReply");
            var sendPortMsg=$(currInput).find(".reportComText").find("textarea").val();

            console.log(sendPortMsg);
            var rootID = articleId, userID = userID, userName =userName,
                reason=sendPortMsg;

            //提交回复
            $.ajax({
                type: "post",
                url: sentComentExpose,
                data:{
                    //"siteID":siteID,
                    "rootID": rootID,
                    "userID": userID,
                    "userName": userName,
                    "reason": sendPortMsg
                },
                dataType : "jsonp",
                jsonp: "jsoncallback",
                jsoncallback:"jsoncallback",
                success: function(data){
                    alert("举报成功！");
                    $(currPortTextarear).addClass('hideTextarea');
                    $(currPortTextarearOther).addClass('hideTextarea');
                    $(currPortTextarearOther).find("textarea").val("");
                    $(currInput).find(".reportComText").find("textarea").val("");

                },
                error: function(){
                    alert("举报失败");
                    $(currPortTextarear).addClass('hideTextarea');
                }
            });
        }

        //直播回复中的举报 直播子评论中评论举报
        $scope.reportComReplay=function ($event,userName) {
            //if($rootScope.uid_fouNder){
            var currInputPar=angular.element($event.target).parent().parent().parent().children();
            console.log("current")
            console.log(currInputPar)
            $(currInputPar).each(function(index,val){
                if(val.className.indexOf('reportComTextReply')!=-1){
                    var cureInput=val;
                    if($(cureInput).hasClass('hideTextarea')){
                        $(cureInput).removeClass("hideTextarea");
                    }else{
                        $(cureInput).addClass("hideTextarea");
                    }
                }
            });

            $(currInputPar).find("textarea").attr("placeholder","举报"+userName+"的理由是：");
            console.log("当前的input")
            console.log($(currInputPar).find("textarea"))
            $(currInputPar).find(".reportComTextReply").focus();

        };


        //直播评论点赞
        $scope.commPraiseAdd=function($event,$index,id){
            var currComPic=angular.element($event.target);
            var userID=uid_fouNder;
            if(!userID){
                userID=0;
            }
            console.log(id)
            console.log("当前点击对象")
            console.log(currComPic)
            var id =id ,type=1,eventType=1, userID = userID,siteID=1,userOtherID='',channel=0;
            $.ajax({
                type: "post",
                url: detailPrasieUrl,
                data:{
                    "id": id,
                    "type": type,
                    "eventType": eventType,
                    "userID": userID,
                    "siteID":siteID,
                    "userOtherID":userOtherID,
                    "channel":channel
                },
                dataType : "jsonp",
                jsonp: "jsoncallback",
                jsoncallback:"jsoncallback",
                success: function(data){
                    $scope.commenCon[$index].countPraise++;
                    $(currComPic[0]).attr("src",'static/thuAc.png');
                },
                error: function(){
                    alert("评论点赞失败");
                }

            });
        };



        /**
         * 直播聊天室详情加载更多
         * */
        $scope.loadMorLiveDetail=function () {
            $scope.liveDataiPage++;
            $http.jsonp(liveDetailData+'sindex=0&id='+linkId+'&lastFileId='+$scope.lastFileId+'&page='+$scope.liveDataiPage+'&jsoncallback=JSON_CALLBACK'
            ).success(function(data,header,config,status){
                $scope.liveDetail=data;
                $scope.liveDetailArray=$scope.liveDetailArray.concat(data.list);
                console.log("加载更多数据")
                console.log($scope.liveDetailArray)
                //所有直播流对象，判断如果vedio中没有对象就是图文直播
                // $scope.liveImgOrVedioObj=data.main.config.videos;
                // if($scope.liveDetail.main.config.videos.length>0){
                //     console.log("加载更多直播url")
                //     console.log($scope.liveImgOrVedioObj[0].webLiveUrl)
                // }
                console.log("详情加载更多")
                console.log($scope.liveDetail)
                if(data.list.length>=20){
                    $scope.loadDetailMoreButtonOne=true;
                }else{
                    $scope.loadDetailMoreButtonOne=false;
                    $scope.noDetailLoadMoreButton=true;
                }
                for(var i=0;i<data.list.length;i++){
                    var value=data.list[i].publishtime;
                    // console.log("时间数组")
                    // console.log(value)
                    var indexSpac=value.indexOf(" ");
                    var lastHourString=value.substring(0,indexSpac);
                    if(!json[lastHourString]){
                        publicArr.push(lastHourString);
                        json[lastHourString] = 1;
                    }
                }
                console.log("加载更多时间数组")
                console.log(publicArr);
                $scope.publicArr=publicArr;
            }).error(function(data,header,config,status){
            });
        }


        //直播详情语音播放当前audio
        $scope.playAudio=function ($event) {
            console.log("当前audio");
            console.log(angular.element($event.target).next());
            var audio=angular.element($event.target).next();
            audio[0].play();
            //时长
            console.log(Math.round(audio[0].duration))
        };
        /*var timeFormat = function(seconds){
         var m = Math.floor(seconds/60)<10 ? "0"+Math.floor(seconds/60) : Math.floor(seconds/60);
         var s = Math.floor(seconds-(m*60))<10 ? "0"+Math.floor(seconds-(m*60)) : Math.floor(seconds-(m*60));
         return m+":"+s;
         };*/
        //直播详情视频播放当前vedio
        $scope.playVedio=function ($event) {
            console.log("当前vedio");
            var currentVedio=angular.element($event.target).parent().parent().find('video');
            console.log(angular.element($event.target).parent().parent().find('video'));
            currentVedio[0].play();
            var control=angular.element($event.target).parent().parent().find('.control');
            console.log("control")
            $(control).css("bottom","0");
            var duration=angular.element($event.target).parent().parent().find('.duration');
            console.log("duration");
            duration[0].innerText=Math.round(currentVedio[0].duration);
            console.log(currentVedio[0].duration);
            angular.element($event.target).css("display","none");
            var btnPlay=angular.element($event.target).parent().parent().find('.btnPlay')
            $(btnPlay).addClass('paused');
            currentVedio.on('timeupdate', function() {
                var currentPos =Math.round(currentVedio[0].currentTime) ;
                var maxduration = currentVedio[0].duration;
                var perc = 100 * currentPos / maxduration;
                var timeBar=angular.element($event.target).parent().parent().find('.timeBar');
                var current=angular.element($event.target).parent().parent().find('.current');
                var timeBall=angular.element($event.target).parent().parent().find('#timeBall');

                $(timeBar).css('width',perc+'%');
                $(timeBall).css('left',perc+'%');
                $(current).text(currentPos);
            })

        };
        //全屏
        $scope.btnFS=function ($event) {
            console.log("当前vedio");
            var currentVedio=angular.element($event.target).parent().parent().parent().find('video')
            console.log(currentVedio);
            if($.isFunction(currentVedio[0].webkitEnterFullscreen)) {
                currentVedio[0].webkitEnterFullscreen();
            }
            else if ($.isFunction(currentVedio[0].mozRequestFullScreen)) {
                currentVedio[0].mozRequestFullScreen();
            }
            else {
                console.log('Your browsers doesn\'t support fullscreen');
            }

        };
        //点击播放三角
        $scope.btnPlay=function ($event) {
            var currentVedio=angular.element($event.target).parent().parent().parent().find('video');
            console.log("当前vedio");
            console.log(currentVedio);
            if(currentVedio[0].paused || currentVedio[0].ended) {
                angular.element($event.target).addClass('paused');
                currentVedio[0].play();
            }
            else {
                angular.element($event.target).removeClass('paused');
                currentVedio[0].pause();
            }
        }

///直播点赞 不需要这些userID=22,userOtherID=111,siteID=1,
        $rootScope.detailAddPraseImagSmall="static/thub.png";
        $scope.detailAddPrase=function () {
            if(doGetCookie(articleId)){
                alert("请不要重复点赞");
                return
            }else{
                $scope.liveDetail.main.countPraise++;
                //console.log("useid");
                //console.log($scope.uid_fouNder);
                //var userID=$rootScope.uid_fouNder;
                $rootScope.detailAddPraseImag="static/14.png";
                $rootScope.detailAddPraseImagSmall="static/thuAc.png";
                var id=articleId,type=0,eventType=1,channel=1;
                //提交回复
                $.ajax({
                    type: "post",
                    url: detailPrasieUrl,
                    data:{
                        "id": id,
                        "type": type,
                        "eventType": eventType,
                        "channel":channel
                    },
                    dataType : "jsonp",
                    jsonp: "jsoncallback",
                    jsoncallback:"jsoncallback",
                    success: function(data){
                        document.cookie=articleId='true';
                    },
                    error: function(){
                        // alert("点赞失败");
                    }
                });

            }
        };
        //直播收藏 需要
        $rootScope.detailAddStorImagSmall="static/18.png";
        $scope.detailAddStor=function () {
            if(uid_fouNder){
                var userID=uid_fouNder;
                $rootScope.detailAddStorImagSmall="static/19.png";
                $rootScope.detailAddStorImag="static/16.png";
                var userID=userID,siteID=1,type=0,id=linkId,channel=0;
                //提交回复
                $http.jsonp(artDetailAddStorUrl+'userID='+userID+'&siteID='+siteID+'&type='+type+'&id='+id+'&channel'+channel+'&jsoncallback=JSON_CALLBACK'
                ).success(function(data,header,config,status){
                    console.log("收藏成功");
                }).error(function(data,header,config,status){

                });
            }else{
                alert("请登录后收藏");
                ssologin();
                //$scope.h5Jump('http://59.108.92.239:9081/SSOv2/user/ssoLogin?code=yxapp&redirectUrl=http://59.108.92.239/amucsite/pad/sso/setCookie.html?&anyUrl=http://59.108.92.239/amucsite/pad/index.html#/detail/'+fileId+'&isAppType=app');
            }

        };

    }])





  /**
   * 视频详情
   * */
  app.controller('detailVedioCtr',
      ['$scope','$location','$http','$rootScope','$routeParams','$sce', function ($scope,$location,$http,$rootScope,$routeParams,$sce) {
          //loading提示
          $("#globalLoading").css({opacity:'1'});
          var articleId = $routeParams.fileId;

          //首次加载隐藏回到顶部按钮
          $(".baToTop").hide();

          //清空分享数据
          //清空视频分享数据
          window.shareUrl='';
          window.shareTitle="";
          window.shareImg="";
          window.shareContent="";
          var shareUrl=$location.absUrl().slice($location.absUrl().indexOf("#")+1);
          window.shareUrl=globalShareUrl+shareUrl;

          // 获取视频详情数据articleId= 2615
          $http.jsonp(detailVedioDataUrl+'articleId='+articleId+'&version=0&jsoncallback=JSON_CALLBACK'
          ).success(function (data, header, config, status) {
              //分享标题
              window.shareTitle=data.title;
              window.shareContent=data.attAbstract;

              $scope.detailVedioObj=data;
              $scope.detailVedioData = data.related;
              $scope.detailVedioUrl=data.videos[0].videoarray[0].videoUrl;
              console.log("视频url");
              console.log($scope.detailVedioUrl);
              console.log("视频");
              console.log(data);
              //直播是否关闭该篇稿件评论功能
              if(data== "" || data == undefined ||data == null){
                  $scope.currentDiscussClosed=0;
              }else{
                  $scope.currentDiscussClosed=data.discussClosed;
              }

              //loading提示
              $("#globalLoading").animate({opacity:'0'},500);

          }).error(function (data, header, config, status) {
          });

          /**
           * 视频详情评论，与其他评论source=0不同
           * */
          var source=artSource;
          //获取最新评论  page=0开始;加载更多评论
          var compage=0;
          //加载更多最新视频评论（只有最新评论有分页）id=3969全替换为articleId*****
          $scope.LoadMoreCom=function () {
              compage++;
              $http.jsonp(newComment+'id='+articleId+'&siteId=1&lastFileId=0&page='+compage+'&source='+source+'&jsoncallback=JSON_CALLBACK'
              ).success(function(data,header,config,status){
                  // 是否还有更多评论
                  $scope.hasMorCom=data.hasMore;
                  $scope.commenCon=$scope.commenCon.concat(data.list);
              }).error(function(data,header,config,status){

              });

          };

          //获取最新视频评论
          $scope.getNewCom=function () {
              $scope.commeInputs=siteConfig.defaultHint;
              //'+articleId+'  '+source+'
              $http.jsonp(newComment+'id='+articleId+'&siteId=1&lastFileId=0&page=0&source='+source+'&jsoncallback=JSON_CALLBACK'
              ).success(function(data,header,config,status){
                  console.log("第一次最新评论");
                  console.log(data);
                  // 是否还有更多评论
                  $scope.hasMorCom=data.hasMore;
                  $scope.commenCon=data.list;
                  $scope.totalCount=data.totalCount;
              }).error(function(data,header,config,status){

              });
          };

                //视频首个评论输入框
                  $scope.sendComFistBtn=function () {
                      console.log(window.uploadFile);
                      if(!window.uploadFile){
                          //视频只提交评论文字
                          var sendMesg=$("#commeInputs").val();
                          console.log(sendMesg);
                          var logUserId=uid_fouNder;
                          console.log("评论用户id")
                          console.log(logUserId)
                          var LogUserName=username_fouNder;
                          //匿名评论
                          if(!uid_fouNder){
                              logUserId=0;
                              LogUserName="pc用户";
                          }
                          var siteID = 1, rootID = articleId, parentID =0 , parentUser ='',
                              parentUserID =0, topic =topic, userID = logUserId
                              , userName = LogUserName, type = 0,content=sendMesg;

                          //提交回复
                          $.ajax({
                              type: "post",
                              url: sentComent,
                              data:{
                                  "siteID":siteID,
                                  "rootID": rootID,
                                  "parentID": parentID,
                                  "parentUser": parentUser,
                                  "parentUserID": parentUserID,
                                  "topic": topic,
                                  "userID": userID,
                                  "userName": userName,
                                  "type": type,
                                  "content":content,
                                  "channel":1,
                                  "sourceType":source
                              },
                              dataType : "json",
                              //jsonp: "jsoncallback",
                              //jsoncallback:"jsoncallback",
                              success: function(data){
                                      console.log(data);
                                      alert("评论成功！");
                                      $scope.getNewCom();
                                      console.log("发送内容为：");
                                      console.log(sendMesg);
                                      $("#commeInputs").val("");

                              },
                              error: function(){
                                  alert("评论失败！2");
                                  $("#commeInputs").val("");
                              }
                          });
                      }else{
                          //提交评论图片和文字
                          //图片提交
                          var uploadFile=window.uploadFile;
                          console.log(window.uploadFile);
                          var formdata = new FormData();
                          formdata.append("Filedata", uploadFile);
                          formdata.append("siteID", 1);
                          formdata.append("location", 0);
                          formdata.append("userId", "0");
                          formdata.append("fileType", "picture");
                          formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                          $.ajax({
                              type:'POST',
                              url: commUpload,
                              processData: false,
                              data: formdata,
                              async:false,
                              contentType: false,    //这个一定要写
                              dataType:'json',
                              success: function(result){
                                  //成功后处理代码
                                  //self.onSuccess(file, result);
                                  //if(self.curUploadFile.length==0){
                                  // 回调全部完成方法
                                  //self.onComplete("全部完成");
                                  console.log("result");
                                  console.log(result)
                                  console.log("上传成功url");
                                  var comimgUrl=JSON.parse(result).fileList[0].url;
                                  console.log(comimgUrl);

                                  setTimeout(function(){
                                      //视频只提交评论文字
                                      var sendMesg=$("#commeInputs").val();
                                      console.log(sendMesg);
                                      var logUserId=uid_fouNder;
                                      console.log("评论用户id")
                                      console.log(logUserId)
                                      var LogUserName=username_fouNder;
                                      //匿名评论
                                      if(!uid_fouNder){
                                          logUserId=0;
                                          LogUserName="pc用户";
                                      }
                                      var siteID = 1, rootID = articleId, parentID =0 , parentUser ='',
                                          parentUserID =0, topic =topic, userID = logUserId
                                          , userName = LogUserName, type = 0,content=sendMesg;

                                      //提交回复
                                      $.ajax({
                                          type: "post",
                                          url: sentComent,
                                          data:{
                                              "siteID":siteID,
                                              "rootID": rootID,
                                              "parentID": parentID,
                                              "parentUser": parentUser,
                                              "parentUserID": parentUserID,
                                              "topic": topic,
                                              "userID": userID,
                                              "userName": userName,
                                              "type": type,
                                              "content":content,
                                              "channel":1,
                                              "sourceType":source,
                                              "imgUrl":comimgUrl
                                          },
                                          dataType : "json",
                                          //jsonp: "jsoncallback",
                                          //jsoncallback:"jsoncallback",
                                          success: function(data){
                                              console.log(data);
                                              alert("评论图片上传成功！");
                                              $scope.getNewCom();
                                              //图片上传成功后，清除当前图片，设置可以重新添加上传图片
                                              $('.img-cont').text("");
                                              $("#file").attr("disabled", false);
                                              //清除全局变量图片
                                              window.uploadFile="";

                                          },
                                          error: function(){
                                              alert("评论失败！2");
                                              $("#commeInputs").val("");
                                          }
                                      });
                                  },1000)

                                  //}
                              },
                              error: function(){
                                  self.onFailure(file);
                              }

                          });

                      }
                  };



          //获取 热门评论 id = '+articleId+'??
          $scope.getHotCom=function () {
              $http.jsonp(hotComment+'id='+articleId+'&siteId=1&source='+source+'&jsoncallback=JSON_CALLBACK'
              ).success(function(data,header,config,status){
                  console.log(data);
                  // 是否还有更多评论
                  $scope.hasMorCom=data.hasMore;
                  //获取评论
                  $scope.commenCon=data.list;
              }).error(function(data,header,config,status){
              });
          };

          //视频类型获取全局配置信息
          $scope.getCommentInfo=function(){
              $http.jsonp(commInfo+'&jsoncallback=JSON_CALLBACK'
              ).success(function(data,header,config,status){
                  console.log("全局评论信息");
                  console.log(data);
                  $scope.siteConfig=data.siteConfig.discuss;
                  //评论框提示语
                  siteConfig.defaultHint=$scope.siteConfig.defaultHint;
                  //官方评论用户名
                  siteConfig.defaultName=$scope.siteConfig.defaultName;
                  $scope.defaultName=$scope.siteConfig.defaultName;
                  //官方评论头像
                  siteConfig.defaultIcon=$scope.siteConfig.defaultIcon;
                  $scope.siteConfigDefaultIcon=$scope.siteConfig.defaultIcon;
                  console.log("官方用户名");
                  console.log($scope.defaultName);
                  //是否关闭全站评论功能
                  $scope.siteConfigAuditType=$scope.siteConfig.auditType;
                  //全局评论颜色问题
                  $scope.commStyleColor=$scope.siteConfig.styleColor;
                  commentStyle=$scope.commStyleColor;
                  $rootScope.changeComStyle();
                  //获取最新和热门评论
                  $scope.getNewCom();
                  //setTimeout(function () {

                  //},1000)
              }).error(function(data,header,config,status){

              });

          };
          $scope.getCommentInfo();


          //视频回复评论
          $scope.replayCom=function ($event,userName) {
              var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
              console.log("current")
              console.log(currInputPar)
              $(currInputPar).each(function(index,val){
                  if(val.className.indexOf('comm_con_input_par')!=-1){
                      var cureInput=val;
                      if($(cureInput).hasClass('hideInput')){
                          $(cureInput).removeClass("hideInput");
                      }else{
                          $(cureInput).addClass("hideInput");
                      }
                  }
              });

              var currInput= $(currInputPar[3]).find("input");
              $(currInput).attr("placeholder","@"+userName+":");
              $(currInput).focus();
          };
          //视频提交评论和上传图片
          $scope.par_input_send=function ($event,parentId,userName,ParentUserID) {
              var currInput=angular.element($event.target).parent().parent().find("input");
              console.log($(currInput).val());
              var sendMesg=$(currInput).val();
              if(!window.uploadFile) {
                  //视频只提交文字
                  var pareDiv=angular.element($event.target).parent().parent();
                  // 提交评论使用
                  $scope.parentId=parentId;
                  console.log($scope.parentId)
                  $scope.userName=userName;
                  console.log($scope.userName)
                  $scope.ParentUserID=ParentUserID;
                  console.log($scope.ParentUserID)
                  var logUserId=uid_fouNder;
                  console.log("评论用户id")
                  console.log(logUserId)
                  var LogUserName=username_fouNder;
                  var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                      parentUserID = $scope.ParentUserID, topic =topic, userID = logUserId
                      , userName = LogUserName, type = 0,content=sendMesg;

                  //提交回复
                  $.ajax({
                      type: "post",
                      url: sentComent,
                      data:{
                          "siteID":siteID,
                          "rootID": rootID,
                          "parentID": parentID,
                          "parentUser": parentUser,
                          "parentUserID": parentUserID,
                          "topic": topic,
                          "userID": userID,
                          "userName": userName,
                          "type": type,
                          "content":content,
                          "channel":1,
                          "sourceType":source
                      },
                      dataType : "json",
                      //jsonp: "jsoncallback",
                      //jsoncallback:"jsoncallback",
                      success: function(data){
                          if(data){
                              console.log(data);
                              alert("评论成功！");
                              $scope.getNewCom();
                              console.log("发送内容为：");
                              console.log(sendMesg);
                              $(currInput).val("");
                              $(pareDiv).addClass('hideInput');
                          }else{
                              alert("评论失败！1");
                          }

                      },
                      error: function(){
                          alert("评论失败！2");
                          $("#comInput").val("");
                          $(pareDiv).addClass('hideInput');
                      }
                  });
              }else{
                  //视频上传图片和文字
                  //既有图片又有文字的评论回复
                  //图片提交
                  var uploadFile=window.uploadFile;
                  console.log(window.uploadFile);
                  var formdata = new FormData();
                  formdata.append("Filedata", uploadFile);
                  formdata.append("siteID", 1);
                  formdata.append("location", 0);
                  formdata.append("userId", "0");
                  formdata.append("fileType", "picture");
                  formdata.append("uniqid", "B715C9A0-D580-46F2-ABD1-F244EA24C934");

                  $.ajax({
                      type:'POST',
                      url: commUpload,
                      processData: false,
                      data: formdata,
                      async:false,
                      contentType: false,    //这个一定要写
                      dataType:'json',
                      success: function(result) {
                          //成功后处理代码
                          //self.onSuccess(file, result);
                          //if(self.curUploadFile.length==0){
                          // 回调全部完成方法
                          //self.onComplete("全部完成");
                          console.log("result");
                          console.log(result)
                          console.log("上传成功url");
                          var comimgUrl = JSON.parse(result).fileList[0].url;
                          console.log(comimgUrl);
                          //获取图片url后再调用接口
                          setTimeout(function(){
                              //视频只提交文字
                              var pareDiv=angular.element($event.target).parent().parent();
                              //清空上传的图片内容
                              var currentImgCon=angular.element($event.target).parent().children().find(".imgCont");
                              //启用上传图片功能
                              var currentUploadInput=angular.element($event.target).parent().children().find(".uploadInput");
                              // 提交评论使用
                              $scope.parentId=parentId;
                              console.log($scope.parentId)
                              $scope.userName=userName;
                              console.log($scope.userName)
                              $scope.ParentUserID=ParentUserID;
                              console.log($scope.ParentUserID)
                              var logUserId=uid_fouNder;
                              console.log("评论用户id")
                              console.log(logUserId)
                              var LogUserName=username_fouNder;
                              var siteID = 1, rootID = articleId, parentID = $scope.parentId, parentUser = $scope.userName,
                                  parentUserID = $scope.ParentUserID, topic =topic, userID = logUserId
                                  , userName = LogUserName, type = 0,content=sendMesg;

                              //提交回复
                              $.ajax({
                                  type: "post",
                                  url: sentComent,
                                  data:{
                                      "siteID":siteID,
                                      "rootID": rootID,
                                      "parentID": parentID,
                                      "parentUser": parentUser,
                                      "parentUserID": parentUserID,
                                      "topic": topic,
                                      "userID": userID,
                                      "userName": userName,
                                      "type": type,
                                      "content":content,
                                      "channel":1,
                                      "sourceType":source,
                                      "imgUrl":comimgUrl
                                  },
                                  dataType : "json",
                                  //jsonp: "jsoncallback",
                                  //jsoncallback:"jsoncallback",
                                  success: function(data){
                                          console.log(data);
                                          alert("评论成功！");
                                          $scope.getNewCom();
                                          console.log("发送内容为：");
                                          console.log(sendMesg);
                                          $(currInput).val("");
                                          $(pareDiv).addClass('hideInput');
                                          //清空长传的图片
                                          $(currentImgCon).text("");
                                          //启用上传图片功能
                                          $(currentUploadInput).attr("disabled", false);
                                          //清除全局变量图片
                                          window.uploadFile="";

                                  },
                                  error: function(){
                                      alert("评论失败！2");
                                      $("#comInput").val("");
                                      $(pareDiv).addClass('hideInput');
                                  }
                              });
                        },1000);
                      },
                      error: function () {
                          alert("评论失败！2");
                          $("#comInput").val("");
                          $(pareDiv).addClass('hideInput');
                      }
                  });
              }

          };

          //视频回复中的举报 视频子评论中评论举报
          $scope.reportComReplay=function ($event,userName) {
              var currInputPar=angular.element($event.target).parent().parent().parent().children();
              console.log("current")
              console.log(currInputPar)
              $(currInputPar).each(function(index,val){
                  if(val.className.indexOf('reportComTextReply')!=-1){
                      var cureInput=val;
                      if($(cureInput).hasClass('hideTextarea')){
                          $(cureInput).removeClass("hideTextarea");
                      }else{
                          $(cureInput).addClass("hideTextarea");
                      }
                  }
              });

              $(currInputPar).find("textarea").attr("placeholder","举报"+userName+"的理由是：");
              console.log("当前的input")
              console.log($(currInputPar).find("textarea"))
              $(currInputPar).find(".reportComTextReply").focus();

          };


          //视频子评论
          $scope.lunchaMorChilCom=true;
          //获取子评论加载更多更多内容 id为每条父评论的id号
          $scope.checkMorChildCom=function (id,index) {
              $scope.lunchaMorChilCom=false;

              $http.jsonp(replayComent+'id='+id+'&page=0&siteId=1&source=0&jsoncallback=JSON_CALLBACK'
              ).success(function(data,header,config,status){
                  //点击查看更多子评论之前
                  $scope.beforLoadMorChid=$scope.commenCon[index].topDiscuss.list;
                  //点击查看更多子评论之后
                  $scope.commenCon[index].topDiscuss.list=data.list;
                  // 是否还有更多评论
                  /*console.log("是否有更多")
                   console.log(data.hasMore)*/
                  $scope.hasNoChildMorCom={};
                  $scope.hasChildMorCom={};
                  if(data.hasMore){
                      $scope.hasChildMorCom.index=true;
                  }else{
                      $scope.hasNoChildMorCom.index=true;

                  }
                  //获取评论
                  // $scope.commenCon=data.list;
              }).error(function(data,header,config,status){
              });
          }

          //视频点赞 不需要这些userID=22,userOtherID=111,siteID=1,
          $rootScope.detailAddPraseImagSmall="static/thub.png";
          $scope.detailAddPrase=function () {
              if(doGetCookie(articleId)){
                  alert("请不要重复点赞");
                  return
              }else{
                  $scope.detailVedioObj.countPraise++;
                  //console.log("useid");
                  //console.log($scope.uid_fouNder);
                  //var userID=$rootScope.uid_fouNder;
                  $rootScope.detailAddPraseImagSmall="static/thuAc.png";
                  var id=articleId,type=0,eventType=1,channel=1;
                  //提交回复
                  $.ajax({
                      type: "post",
                      url: detailPrasieUrl,
                      data:{
                          "id": id,
                          "type": type,
                          "eventType": eventType,
                          "channel":channel
                      },
                      dataType : "jsonp",
                      jsonp: "jsoncallback",
                      jsoncallback:"jsoncallback",
                      success: function(data){
                          console.log("点赞成功")
                          document.cookie=articleId='true';
                      },
                      error: function(){
                          // alert("点赞失败");
                      }
                  });
              }
          };

          //视频收藏
          $rootScope.detailAddStorImagSmall="static/18.png";
          $scope.detailAddStor=function () {
              if(uid_fouNder){
                  var userID=uid_fouNder;
                  $rootScope.detailAddStorImagSmall="static/19.png";
                  $rootScope.detailAddStorImag="static/16.png";
                  var userID=userID,siteID=1,type=0,id=linkId,channel=0;
                  //提交回复
                  $http.jsonp(artDetailAddStorUrl+'userID='+userID+'&siteID='+siteID+'&type='+type+'&id='+id+'&channel'+channel+'&jsoncallback=JSON_CALLBACK'
                  ).success(function(data,header,config,status){
                      console.log("收藏成功");
                  }).error(function(data,header,config,status){

                  });
              }else{
                  alert("请登录后收藏");
                  ssologin();
                 // $scope.h5Jump('http://59.108.92.239:9081/SSOv2/user/ssoLogin?code=yxapp&redirectUrl=http://59.108.92.239/amucsite/pad/sso/setCookie.html?&anyUrl=http://59.108.92.239/amucsite/pad/index.html#/detail/'+articleId+'&isAppType=app');
              }
          };

          //视频评论举报
          $scope.reportCom=function ($event,userName) {
              //if($rootScope.uid_fouNder){
              var currInputPar=angular.element($event.target).parent().parent().parent().parent().children();
              console.log("current")
              console.log(currInputPar)
              if($(currInputPar).find(".reportComText").hasClass('hideTextarea')){
                  $(currInputPar).find(".reportComText").removeClass("hideTextarea");
              }else{
                  $(currInputPar).find(".reportComText").addClass("hideTextarea");
              }
              $(currInputPar).find(".reportComText").find("textarea").attr("placeholder","举报"+userName+"的理由是：");
              $(currInputPar).find(".reportComText").focus();
              //}else{
              //    alert("请登录后再回复");
              //}
          };

          //视频举报提交
          $scope.par_input_port_send=function($event,id,userName,userID){
              var currInput=angular.element($event.target).parent().parent().parent().parent().children();
              var currPortTextarear=$(currInput).find(".reportComText");
              var sendPortMsg=$(currInput).find(".reportComText").find("textarea").val();
              console.log(sendPortMsg);
              var rootID = articleId, userID = userID, userName =userName,
                  reason=sendPortMsg;

              //提交回复
              $.ajax({
                  type: "post",
                  url: sentComentExpose,
                  data:{
                      "rootID": rootID,
                      "userID": userID,
                      "userName": userName,
                      "reason": sendPortMsg
                  },
                  dataType : "jsonp",
                  jsonp: "jsoncallback",
                  jsoncallback:"jsoncallback",
                  success: function(data){
                      alert("举报成功！");
                      $(currPortTextarear).addClass('hideTextarea');
                      $(currInput).find(".reportComText").find("textarea").val("");
                  },
                  error: function(){
                      alert("举报失败");
                      $(currPortTextarear).addClass('hideTextarea');
                  }
              });
          }


          //视频评论点赞
          $scope.commPraiseAdd=function($event,$index,id){
              var currComPic=angular.element($event.target);
              var userID=uid_fouNder;
              if(!userID){
                  userID=0;
              }
              console.log(id)
              console.log("当前点击对象")
              console.log(currComPic)
              var id =id ,type=1,eventType=1, userID = userID,siteID=1,userOtherID='',channel=0;
              $.ajax({
                  type: "post",
                  url: detailPrasieUrl,
                  data:{
                      "id": id,
                      "type": type,
                      "eventType": eventType,
                      "userID": userID,
                      "siteID":siteID,
                      "userOtherID":userOtherID,
                      "channel":channel
                  },
                  dataType : "jsonp",
                  jsonp: "jsoncallback",
                  jsoncallback:"jsoncallback",
                  success: function(data){
                      $scope.commenCon[$index].countPraise++;
                      $(currComPic[0]).attr("src",'static/thuAc.png');
                  },
                  error: function(){
                      alert("评论点赞失败");
                  }

              });
          };


      }]);